//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.baseline.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.google.common.base.Strings;
import com.hustcad.plm.basic.util.TyCommonExtUtil;
import com.hustcad.plm.basic.util.TyplmEntityBaseUtil;
import com.hustcad.plm.basic.util.TyplmLoggerUtil;
import com.hustcad.plm.caddocapi.service.TyplmCADDocService;
import com.hustcad.plm.pdm.access.model.dto.AccessBatchDTO;
import com.hustcad.plm.pdm.access.service.TyplmAccessJudgeService;
import com.hustcad.plm.pdm.basedrule.dto.TyplmBaseRuleBoundedObjDTO;
import com.hustcad.plm.pdm.basedrule.dto.TyplmBaseRuleTypeDTO;
import com.hustcad.plm.pdm.basedrule.service.TyplmBasedRuleService;
import com.hustcad.plm.pdm.basedrule.vo.TyplmBasedLifeStageVO;
import com.hustcad.plm.pdm.baseline.mapper.TyplmBaseLineMapper;
import com.hustcad.plm.pdm.baseline.mapper.TyplmBaseLineMemberMapper;
import com.hustcad.plm.pdm.baseline.module.constant.BaseLineConstant;
import com.hustcad.plm.pdm.baseline.module.constant.BaseLineErrorCodeEnum;
import com.hustcad.plm.pdm.baseline.module.constant.BaseLineConstant.OperType;
import com.hustcad.plm.pdm.baseline.module.dto.BaseLineDTO;
import com.hustcad.plm.pdm.baseline.module.dto.CompareBaseLineReportDTO;
import com.hustcad.plm.pdm.baseline.module.dto.QueryBaseLineConditionsDTO;
import com.hustcad.plm.pdm.baseline.module.dto.QueryBaseLineDTO;
import com.hustcad.plm.pdm.baseline.module.dto.TyplmBaseLineCompareSearchData;
import com.hustcad.plm.pdm.baseline.module.dto.TyplmBaseLineMemberParam;
import com.hustcad.plm.pdm.baseline.module.dto.TyplmBaseLineParam;
import com.hustcad.plm.pdm.baseline.module.vo.ObjectVO;
import com.hustcad.plm.pdm.baseline.module.vo.QueryBaseLineVO;
import com.hustcad.plm.pdm.baseline.module.vo.TyplmBaseLineCompareObjInfo;
import com.hustcad.plm.pdm.baseline.module.vo.TyplmBaseLineComparisonResultsVO;
import com.hustcad.plm.pdm.baseline.module.vo.TyplmBaseLineObjBaseVO;
import com.hustcad.plm.pdm.baseline.service.TyplmBaseLineMemberService;
import com.hustcad.plm.pdm.baseline.service.TyplmBaseLineService;
import com.hustcad.plm.pdm.caddoc.model.vo.AttributeKeyValueVO;
import com.hustcad.plm.pdm.classification.service.TyplmClassificationService;
import com.hustcad.plm.pdm.code.model.constant.CodeErrorCodeEnum;
import com.hustcad.plm.pdm.code.model.dto.TyplmBatchCodeParam;
import com.hustcad.plm.pdm.code.service.TyplmCodeService;
import com.hustcad.plm.pdm.common.factory.TyBusinessEntityService;
import com.hustcad.plm.pdm.common.service.TyplmCommonEntityService;
import com.hustcad.plm.pdm.common.util.CommonUtil;
import com.hustcad.plm.pdm.common.util.TyplmPermissionsUtil;
import com.hustcad.plm.pdm.container.service.TyplmContainerService;
import com.hustcad.plm.pdm.enumeration.service.TyplmLocalePropertyValueService;
import com.hustcad.plm.pdm.folder.model.constant.FolderQueryConstant;
import com.hustcad.plm.pdm.folder.service.TyplmCabinetService;
import com.hustcad.plm.pdm.folder.service.TyplmFolderMemberLinkService;
import com.hustcad.plm.pdm.folder.service.TyplmProductFolderService;
import com.hustcad.plm.pdm.folder.service.TyplmSubFolderLinkService;
import com.hustcad.plm.pdm.iba.service.TyplmAttributeDefService;
import com.hustcad.plm.pdm.iba.service.TyplmAttributeService;
import com.hustcad.plm.pdm.iba.service.TyplmAttributeValueService;
import com.hustcad.plm.pdm.iba.service.TyplmReferenceValueService;
import com.hustcad.plm.pdm.lifestage.model.dto.NewLifeCycleStateHistoryDTO;
import com.hustcad.plm.pdm.lifestage.model.dto.TyLifeCycleTemplateAndStageDTO;
import com.hustcad.plm.pdm.lifestage.model.dto.TyTemplateAndStatusDTO;
import com.hustcad.plm.pdm.lifestage.service.TyplmLifeCycleHistoryService;
import com.hustcad.plm.pdm.lifestage.service.TyplmLifecycleStageTemplateService;
import com.hustcad.plm.pdm.lifestage.service.TyplmLifecycleTemplateService;
import com.hustcad.plm.pdm.lifestage.service.TyplmObjectHistoryService;
import com.hustcad.plm.pdm.type.model.constant.TyCommonConstant;
import com.hustcad.plm.pdm.type.model.vo.TypeVueVO;
import com.hustcad.plm.pdm.type.service.TyplmTypeExtService;
import com.hustcad.plm.pdm.type.service.TyplmTypeService;
import com.hustcad.plm.pdm.user.model.vo.ContainerVO;
import com.hustcad.plm.pdm.user.service.TyplmUserService;
import com.ty.basic.common.ITyLifecycleHelper;
import com.ty.basic.dto.TableParamDTO;
import com.ty.basic.entity.CTyEntityBaseDO;
import com.ty.basic.entity.IdentifierEntity;
import com.ty.basic.entity.TyBaseObject;
import com.ty.basic.entity.baseline.BaseLineDO;
import com.ty.basic.entity.cad.CADDocDO;
import com.ty.basic.entity.folder.CabinetDO;
import com.ty.basic.entity.folder.FolderMemberLinkDO;
import com.ty.basic.entity.folder.SubfolderDO;
import com.ty.basic.entity.lifecycle.LifeCycleHistoryDO;
import com.ty.basic.entity.lifecycle.LifeCycleStageTemplateDO;
import com.ty.basic.entity.lifecycle.LifeCycleTemplateDO;
import com.ty.basic.entity.org.UserDO;
import com.ty.basic.entity.type.TypeDO;
import com.ty.basic.enums.StatusActionEnum;
import com.ty.basic.handler.exceptionhandler.exception.ResponseCodeEnum;
import com.ty.basic.handler.exceptionhandler.exception.TyException;
import com.ty.basic.service.snow.SnowflakeIdComponent;
import com.ty.basic.session.RequestContext;
import com.ty.basic.session.TyAccountContext;
import com.ty.basic.util.StringUtil;
import com.ty.basic.utils.BatchQueryHelper;
import com.ty.basic.vo.AttributeVO;
import com.ty.basic.vo.TyAttributeDefMapVO;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

@Service
@Transactional(
        rollbackFor = {Exception.class}
)
public class TyplmBaseLineServiceImpl implements TyplmBaseLineService, ITyLifecycleHelper, TyBusinessEntityService {
    private static final Logger log = LoggerFactory.getLogger(TyplmBaseLineServiceImpl.class);
    private static String diff = "diff";
    private static String baseline = "baseline";
    private static String attr = "attr";
    private static String def = "def";
    private static String blod = "blod";
    private static String bordtop = "bordtop";
    private static String bordleft = "bordleft";
    private static String bordright = "bordright";
    private static String bordbottom = "bordbottom";
    private static String title = "title";
    private static String name = "name";
    private static String description = "description";
    private static String lockor = "lockor";
    private static String isProtected = "isProtected";
    private static String lifecyclestage = "lifecyclestage";
    private static final IdentifierEntity IDENTIFIER_NULL = null;
    private static final int BATCHNUM_EXCEED = 20;
    private static final int ISLOCKED = 1;
    private static final BaseLineDO NULL = null;
    private static final String PARAM_CONTAINER_ID = "containerId";
    @Resource
    private TyplmPermissionsUtil typlmPermissionsUtil;
    @Resource
    private TyplmCabinetService typlmCabinetService;
    @Resource
    private TyplmBaseLineMapper typlmBaseLineMapper;
    @Resource
    private TyplmUserService typlmUserService;
    @Resource
    private TyplmSubFolderLinkService typlmSubFolderLinkService;
    @Autowired
    private SnowflakeIdComponent snowflakeIdComponent;
    @Autowired
    private TyplmObjectHistoryService typlmObjectHistoryService;
    @Autowired
    private TyplmContainerService typlmContainerService;
    @Autowired
    private TyplmLifecycleStageTemplateService typlmLifecycleStageTemplateService;
    @Autowired
    private TyplmFolderMemberLinkService typlmFolderMemberLinkService;
    @Resource
    private TyplmLifeCycleHistoryService typlmLifeCycleHistoryService;
    @Autowired
    private TyplmTypeService typlmTypeService;
    @Resource
    private TyplmBaseLineMemberService typlmBaseLineMemberService;
    @Resource
    private TyplmBasedRuleService typlmBasedRuleService;
    @Resource
    private TyplmLifecycleTemplateService typlmLifecycleTemplateService;
    @Resource
    private TyplmCommonEntityService typlmCommonEntityService;
    @Resource
    private TyplmCodeService typlmCodeService;
    @Resource
    private TyplmReferenceValueService typlmReferenceValueService;
    @Resource
    TyplmAttributeValueService typlmAttributeValueService;
    @Resource
    private TyplmAttributeService typlmAttributeService;
    @Resource
    private TyplmClassificationService typlmClassificationService;
    @Resource
    private TyplmLocalePropertyValueService typlmLocalePropertyValueService;
    @Resource
    private TyplmProductFolderService typlmProductFolderService;
    @Resource
    private TyplmBaseLineMemberMapper typlmBaseLineMemberMapper;
    @Resource
    private TyplmAccessJudgeService typlmAccessJudgeService;
    @Resource
    private TyplmTypeExtService typlmTypeExtService;
    @Resource
    private TyplmAttributeDefService typlmAttributeDefService;
    @Resource
    private TyplmCADDocService typlmCADDocService;

    private void baseLineIsExit(List<BigInteger> oidList, List<BaseLineDO> baseLineDOS) {
        TyplmLoggerUtil.debug(log, () -> "baseLineIsExit ==> oidList =【{}】,baseLineDOS=【{}】", () -> new Object[]{JSON.toJSONString(oidList), JSON.toJSONString(baseLineDOS)});
        if (baseLineDOS.size() != oidList.size()) {
            List<BigInteger> notExistOid = new ArrayList();
            Map<BigInteger, List<BaseLineDO>> baseLineDOMap = (Map)baseLineDOS.stream().collect(Collectors.groupingBy(BaseLineDO::getOid));

            for(BigInteger oid : oidList) {
                if (CollectionUtils.isEmpty((Collection)baseLineDOMap.get(oid))) {
                    notExistOid.add(oid);
                }
            }

            TyplmLoggerUtil.debug(log, () -> "baseLineIsExit ==> notExistOid =【{}】", () -> new Object[]{JSON.toJSONString(notExistOid)});
            oidList.removeAll(notExistOid);
        }

    }

    public List<QueryBaseLineVO> getBaseLineInfoByOid(List<String> oids, String userOid) {
        TyplmLoggerUtil.debug(log, () -> "getBaseLineInfoByOid ==> oids =【{}】", () -> new Object[]{JSON.toJSONString(oids)});
        List<String> errorOid = (List)oids.stream().filter((item) -> !StringUtil.isNumeric(item)).distinct().collect(Collectors.toList());
        List<BigInteger> oidList = (List)oids.stream().filter(StringUtil::isNumeric).distinct().map(BigInteger::new).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(errorOid)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_INTEGER_NEEDED, new String[]{StringUtils.join(errorOid, ",")})));
        } else {
            List<BaseLineDO> baseLineDOS = BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMapper.queryBaseLineByOid(new ArrayList(list)));
            TyplmLoggerUtil.debug(log, () -> "getBaseLineInfoByOid ==> baseLineDOS =【{}】,oidList=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDOS), JSON.toJSONString(oidList)});
            this.baseLineIsExit(oidList, baseLineDOS);
            if (CollectionUtils.isEmpty(oidList)) {
                return Collections.emptyList();
            } else {
                UserDO userDO = this.typlmUserService.queryUserByKey(new BigInteger(userOid));
                List<TyBaseObject> objects = new ArrayList();
                List<String> permissions = new ArrayList();
                baseLineDOS.forEach((object) -> {
                    permissions.add("读取");
                    objects.add(object);
                });
                TyplmLoggerUtil.debug(log, () -> "getBaseLineInfoByOid-checkObjectPermissionList ==> objects =【{}】,permissions=【{}】", () -> new Object[]{JSON.toJSONString(objects), JSON.toJSONString(permissions)});
                this.typlmPermissionsUtil.checkObjectPermissionList(userDO, objects, permissions);
                List<QueryBaseLineVO> queryBaseLineVOList = BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMapper.getBaseLineInfoByOid(new ArrayList(list)));
                List<BigInteger> subFolderIds = new ArrayList();

                for(QueryBaseLineVO queryBaseLineVO : queryBaseLineVOList) {
                    if (queryBaseLineVO.getFolderId() != null) {
                        subFolderIds.add(new BigInteger(queryBaseLineVO.getFolderId()));
                    }
                }

                Map<BigInteger, String> bigIntegerStringMap = this.typlmProductFolderService.recursiveQueryFolderPathByIdList(subFolderIds);

                for(int i = 0; i < baseLineDOS.size(); ++i) {
                    QueryBaseLineVO queryBaseLineVO = (QueryBaseLineVO)queryBaseLineVOList.get(i);
                    BigInteger subfolderId = StringUtils.isEmpty(queryBaseLineVO.getFolderId()) ? BigInteger.ZERO : new BigInteger(queryBaseLineVO.getFolderId());
                    if (bigIntegerStringMap.containsKey(subfolderId)) {
                        queryBaseLineVO.setFolderPath((String)bigIntegerStringMap.get(subfolderId));
                    }

                    BaseLineDO baseLineDO = (BaseLineDO)baseLineDOS.get(i);
                    boolean flag = Objects.isNull(baseLineDO.getLockdate()) && (BigInteger.ZERO.equals(baseLineDO.getLockeroid()) || TyplmEntityBaseUtil.isEmptyOid(baseLineDO.getLockeroid())) && StringUtils.isEmpty(baseLineDO.getLockerotype());
                    String lock = flag ? "N" : "Y";
                    queryBaseLineVO.setLock(lock);
                }

                TyplmLoggerUtil.debug(log, () -> "getBaseLineInfoByOid ==> queryBaseLineVOList =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVOList)});
                return queryBaseLineVOList;
            }
        }
    }

    private boolean pathFormatIsTrue(String folderPath) {
        Boolean flag = true;
        int firstIndex = folderPath.indexOf("/");
        if (folderPath.contains("//") || firstIndex != 0) {
            flag = false;
        }

        return flag;
    }

    private void checkFolderAndContainer(QueryBaseLineConditionsDTO queryBaseLineConditionsDTO) {
        TyplmLoggerUtil.debug(log, () -> "checkFolderAndContainer ==> queryBaseLineConditionsDTO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineConditionsDTO)});
        String folderId = queryBaseLineConditionsDTO.getFolderId();
        String folderPath = queryBaseLineConditionsDTO.getFolderPath();
        String containerId = queryBaseLineConditionsDTO.getContainerId();
        String containerType = queryBaseLineConditionsDTO.getContainerType();
        if (StringUtil.isNotEmpty(folderId)) {
            this.validateFolderAndContainer(queryBaseLineConditionsDTO, folderId, containerId, containerType);
        } else {
            this.validateFolderPathAndContainer(queryBaseLineConditionsDTO, folderPath, containerId, containerType);
        }

    }

    private void validateFolderPathAndContainer(QueryBaseLineConditionsDTO queryBaseLineConditionsDTO, String folderPath, String containerId, String containerType) {
        TyplmLoggerUtil.debug(log, () -> "validateFolderPathAndContainer ==> queryBaseLineConditionsDTO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineConditionsDTO)});
        if (StringUtils.isNotEmpty(folderPath)) {
            if (StringUtils.isAnyEmpty(new CharSequence[]{containerId, containerType})) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"folderPath,containerId,containerType"});
            }

            if (!StringUtil.isDigits(containerId)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"containerId", containerId});
            }

            if (!this.pathFormatIsTrue(folderPath)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"folderPath", folderPath});
            }

            this.queryFolderByPathAndContainer(queryBaseLineConditionsDTO, folderPath, containerId, containerType);
        }

        if (!StringUtils.isAllEmpty(new CharSequence[]{containerId, containerType}) && !StringUtils.isNoneEmpty(new CharSequence[]{containerId, containerType})) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"containerId,containerType"});
        }

        if (StringUtils.isNoneEmpty(new CharSequence[]{containerId, containerType}) && !StringUtil.isDigits(containerId)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"containerId", containerId});
        }

    }

    private void validateFolderAndContainer(QueryBaseLineConditionsDTO queryBaseLineConditionsDTO, String folderId, String containerId, String containerType) {
        if (!StringUtil.isDigits(folderId)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"folderId", folderId});
        }

        if ("0".equals(folderId) && StringUtils.isAnyEmpty(new CharSequence[]{containerId, containerType})) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"containerId,containerType"});
        }

        if (!"0".equals(folderId)) {
            containerId = "";
            containerType = "";
            queryBaseLineConditionsDTO.setContainerId((String)StringUtils.firstNonEmpty(new String[0]));
            queryBaseLineConditionsDTO.setContainerType((String)StringUtils.firstNonEmpty(new String[0]));
        }

        if (StringUtils.isNoneEmpty(new CharSequence[]{containerId, containerType}) && !StringUtil.isDigits(containerId)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"containerId", containerId});
        }

    }

    private void queryFolderByPathAndContainer(QueryBaseLineConditionsDTO queryBaseLineConditionsDTO, String folderPath, String containerId, String containerType) {
        if ("/".equals(folderPath)) {
            queryBaseLineConditionsDTO.setFolderId("0");
        } else {
            ContainerVO containerVO = this.typlmContainerService.getContainerVOByID(containerType, containerId);
            SubfolderDO subfolderDO = this.typlmSubFolderLinkService.querySubFolderByFullPathAndParent(new BigInteger(containerVO.getDefaultcabinetoid()), containerVO.getDefaultcabinetotype(), folderPath);
            if (ObjectUtils.isEmpty(subfolderDO)) {
                queryBaseLineConditionsDTO.setFolderId("-1");
            } else {
                queryBaseLineConditionsDTO.setFolderId(subfolderDO.getOid().toString());
            }
        }

    }

    public PageInfo<QueryBaseLineVO> batchQueryBaseLine(QueryBaseLineDTO queryBaseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "batchQueryBaseLine ==> queryBaseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineDTO)});
        QueryBaseLineConditionsDTO queryBaseLineConditionsDTO = queryBaseLineDTO.getQueryConditions();
        this.checkFolderAndContainer(queryBaseLineConditionsDTO);
        TyplmLoggerUtil.debug(log, () -> "batchQueryBaseLine validate==> 验证合法性queryBaseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineDTO)});
        queryBaseLineDTO.validate();
        TyplmLoggerUtil.debug(log, () -> "batchQueryBaseLine checkFieldIsNull ==> 验证入参是否全为空,queryBaseLineConditionsDTO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineConditionsDTO)});
        queryBaseLineConditionsDTO.checkFieldIsNull();
        PageMethod.startPage(queryBaseLineDTO.getCurPage(), queryBaseLineDTO.getPageSize());
        List<QueryBaseLineVO> queryBaseLineVOList = this.typlmBaseLineMapper.batchQueryBaseLine(queryBaseLineDTO);
        TyplmLoggerUtil.debug(log, () -> "batchQueryBaseLine ==> queryBaseLineVOList =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVOList)});
        return new PageInfo(queryBaseLineVOList);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public BigInteger insertBaseLine(BaseLineDTO baseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "insertBaseLine ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
        if (ObjectUtils.isNotEmpty(baseLineDTO)) {
            if (ObjectUtils.isEmpty(TyAccountContext.getUser())) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_USER_NOT_FOUND, new String[]{"" + TyAccountContext.getUser() + ""});
            }

            if (StringUtils.isEmpty(baseLineDTO.getFolderPath()) && StringUtils.isEmpty(baseLineDTO.getFolderId())) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"folderId or folderPath"});
            }

            this.checkBaseLineData(baseLineDTO);
            BaseLineDO baseLineDO = this.setBaseLineDO(baseLineDTO);
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            TypeDO typeDO = this.setType(baseLineDTO, baseLineDO);
            this.setLockAndStrict(baseLineDO, baseLineDTO);
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine setLockAndStrict==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            this.setSubfolderDOAndContainerVO(OperType.CREATE, baseLineDO, baseLineDTO, "创建");
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine setSubfolderDOAndContainerVO==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            this.queryAndSetCreateLifecycle(baseLineDTO, baseLineDO, typeDO);
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine queryAndSetCreateLifecycle==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            this.typlmBaseLineMapper.insert(baseLineDO);
            NewLifeCycleStateHistoryDTO newLifeCycleStateHistoryDTO = new NewLifeCycleStateHistoryDTO();
            newLifeCycleStateHistoryDTO.setUserDO(TyAccountContext.getUser());
            newLifeCycleStateHistoryDTO.setLifecyclestagekey(baseLineDO.getLifecyclestagekey());
            newLifeCycleStateHistoryDTO.setState(baseLineDO.getLifecyclestagekey());
            newLifeCycleStateHistoryDTO.setBaseObject(baseLineDO);
            newLifeCycleStateHistoryDTO.setAction(StatusActionEnum.CREATE);
            List<NewLifeCycleStateHistoryDTO> newLifeCycleStateHistoryDTOS = new ArrayList();
            newLifeCycleStateHistoryDTOS.add(newLifeCycleStateHistoryDTO);
            this.typlmLifeCycleHistoryService.newLifeCycleStateHistory(newLifeCycleStateHistoryDTOS);
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine insertFolderMemberLink==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            this.insertFolderMemberLink(baseLineDO);
            this.insertBaseLineExtend(baseLineDTO, baseLineDO);
            TyplmLoggerUtil.debug(log, () -> "insertBaseLine ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            return baseLineDO.getOid();
        } else {
            return BigInteger.ZERO;
        }
    }

    private void insertBaseLineExtend(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO) {
        TyplmLoggerUtil.debug(log, () -> "insertBaseLineExtend 分类IBA信息 ==> baseLineDTO =【{}】,baseLineDO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(baseLineDO)});
        if (ObjectUtils.isNotEmpty(baseLineDTO.getClassId())) {
            this.typlmReferenceValueService.insertReferenceValueByObj(new BigInteger(baseLineDTO.getClassId()), "ty.inteplm.type.CTyClassification", baseLineDO.getOid(), baseLineDO.getOtype());
        }

        if (ObjectUtils.isNotEmpty(baseLineDTO.getIbaAttributeMap())) {
            this.typlmAttributeValueService.saveIBAbyMap(baseLineDTO.getIbaAttributeMap(), baseLineDO, true);
        }

    }

    private void checkBaseLineData(BaseLineDTO baseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "checkBaseLineData ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
        if (ObjectUtils.isEmpty(baseLineDTO.getNumber())) {
            throw BaseLineErrorCodeEnum.BASELINE_PARAM_NUMBER_NULL_ERROR.getException(new Object[0]);
        } else if (baseLineDTO.getNumber().trim().length() > 200) {
            throw BaseLineErrorCodeEnum.BASELINE_PARAM_NUMBER_LENGTH_ERROR.getException(new Object[0]);
        } else {
            List<BigInteger> oidList = this.typlmBaseLineMapper.selectBaseLineByIgnoreNumber(baseLineDTO.getNumber().toUpperCase(Locale.ENGLISH));
            if (!CollectionUtils.isEmpty(oidList)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_OBJECT_EXIST, new String[]{"BaselineNumber: " + baseLineDTO.getNumber()});
            }

            if (ObjectUtils.isEmpty(baseLineDTO.getName())) {
                throw BaseLineErrorCodeEnum.BASELINE_PARAM_NAME_NULL_ERROR.getException(new Object[0]);
            } else if (baseLineDTO.getName().trim().length() > 200) {
                throw BaseLineErrorCodeEnum.BASELINE_PARAM_NAME_LENGTH_ERROR.getException(new Object[0]);
            }
        }
    }

    private BaseLineDO setSubfolderDOAndContainerVO(BaseLineConstant.OperType operType, BaseLineDO baseLineDO, BaseLineDTO baseLineDTO, String permissionName) {
        TyplmLoggerUtil.debug(log, () -> "setSubfolderDOAndContainerVO ==> baseLineDO =【{}】,baseLineDTO=【{}】,permissionName=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO), JSON.toJSONString(baseLineDTO), permissionName});
        if (StringUtils.isBlank(baseLineDTO.getFolderPath()) && StringUtils.isBlank(baseLineDTO.getFolderId()) && StringUtils.equals("修改", permissionName)) {
            return baseLineDO;
        } else {
            if (StringUtils.isNotBlank(baseLineDTO.getFolderPath()) && !this.pathFormatIsTrue(baseLineDTO.getFolderPath())) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"folderPath", baseLineDTO.getFolderPath()});
            }

            SubfolderDO subfolderDO = this.folderIdPress(baseLineDTO);
            CabinetDO cabinetDO = null;
            ContainerVO containerVO = new ContainerVO();
            if (ObjectUtils.isNotEmpty(subfolderDO)) {
                if (ObjectUtils.isNotEmpty(subfolderDO.getContaineroid())) {
                    containerVO = this.typlmContainerService.getContainerVO(subfolderDO.getContainerotype(), subfolderDO.getContaineroid().toString(), (String)null);
                }
            } else {
                containerVO = this.getContainerVO(baseLineDTO);
                cabinetDO = this.typlmCabinetService.queryCabinetByOid(CommonUtil.stringToBigIntegers(containerVO.getDefaultcabinetoid()));
            }

            this.setContainerInfo(baseLineDO, subfolderDO, containerVO);
            String containerType = baseLineDO.getContainerotype();
            if ("ty.inteplm.domain.CTyOrgContainer".equalsIgnoreCase(containerType) || "ty.inteplm.domain.CTySiteContainer".equalsIgnoreCase(containerType)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_ENUM_NOT_CONTAINERS_ERROR, new String[]{"containerType", containerType, "product,library,project"});
            }

            this.initLifecycleTemplate(baseLineDO, permissionName, baseLineDTO.getLifecycleTemplateOid(), baseLineDTO.getLifecycleTemplateName());
            this.checkPermission(operType, TyAccountContext.getUser(), containerVO, baseLineDO, cabinetDO, subfolderDO);
            TyplmLoggerUtil.debug(log, () -> "setSubfolderDOAndContainerVO ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            return baseLineDO;
        }
    }

    private void checkPermission(BaseLineConstant.OperType operType, UserDO userDO, ContainerVO containerVO, TyBaseObject tyBaseObject, CabinetDO cabinetDO, SubfolderDO subfolderDO) {
        List<TyBaseObject> objects = new ArrayList();
        List<String> permissionList = new ArrayList();
        if (operType == OperType.CREATE) {
            if (Objects.nonNull(containerVO.getContainerDO())) {
                permissionList.add("读取");
                objects.add(containerVO.getContainerDO());
            }

            if (!Objects.isNull(cabinetDO)) {
                objects.add(cabinetDO);
                permissionList.add("读取_修改");
            }

            if (Objects.nonNull(subfolderDO)) {
                objects.add(subfolderDO);
                permissionList.add("读取_修改");
            }

            if (!Objects.isNull(tyBaseObject)) {
                objects.add(tyBaseObject);
                permissionList.add("创建");
            }
        }

        TyplmLoggerUtil.debug(log, () -> "checkPermission校验权限,checkObjectPermission ==> userDO =【{}】,objects=【{}】,permissionList=【{}】", () -> new Object[]{JSON.toJSONString(userDO), JSON.toJSONString(objects), JSON.toJSONString(permissionList)});
        this.typlmPermissionsUtil.checkObjectPermission(userDO, objects, permissionList);
    }

    private SubfolderDO folderIdPress(BaseLineDTO baseLineDTO) {
        if (StringUtils.isNotBlank(baseLineDTO.getFolderId())) {
            if (!StringUtil.isNumeric(baseLineDTO.getFolderId())) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_NUMBER_NEEDED, new String[]{"folderId:" + baseLineDTO.getFolderId()})));
            }

            if (!(new BigInteger(baseLineDTO.getFolderId())).equals(BigInteger.ZERO)) {
                this.strId2NumberId(baseLineDTO.getFolderId());
                return this.typlmSubFolderLinkService.getSubfolderDO((BigInteger)null, (String)null, baseLineDTO.getFolderId(), (String)null);
            }
        }

        if (StringUtils.isNotBlank(baseLineDTO.getFolderPath()) && !StringUtils.equals(baseLineDTO.getFolderPath(), "/")) {
            ContainerVO containerVO1 = this.getContainerVO(baseLineDTO);
            BigInteger cabinetOid = CommonUtil.stringToBigInteger(containerVO1.getDefaultcabinetoid());
            return this.typlmSubFolderLinkService.getSubfolderDO(cabinetOid, containerVO1.getDefaultcabinetotype(), (String)null, baseLineDTO.getFolderPath());
        } else {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"folderId or folderPath"})));
        }
    }

    private ContainerVO getContainerVO(BaseLineDTO baseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "getContainerVO ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
        if (StringUtil.isNotEmpty(baseLineDTO.getContainerType())) {
            if (StringUtil.isNotEmpty(baseLineDTO.getContainerId())) {
                if (!StringUtil.isNumeric(baseLineDTO.getContainerId())) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_NUMBER_NEEDED, new String[]{"containerId" + baseLineDTO.getContainerId()})));
                }

                this.strId2NumberId(baseLineDTO.getContainerId());
                return this.typlmContainerService.getContainerVOByID(baseLineDTO.getContainerType(), baseLineDTO.getContainerId());
            }

            if (StringUtil.isNotEmpty(baseLineDTO.getContainerName())) {
                return this.typlmContainerService.getContainerVOByName(baseLineDTO.getContainerType(), baseLineDTO.getContainerName());
            }

            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"containerId or containerName"});
        }

        throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"containerType"})));
    }

    private BigInteger strId2NumberId(String strId) {
        TyplmLoggerUtil.debug(log, () -> "strId2NumberId ==> strId =【{}】", () -> new Object[]{strId});
        BigInteger numId = BigInteger.ZERO;

        try {
            if (Strings.isNullOrEmpty(strId)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{strId});
            }

            numId = new BigInteger(strId);
        } catch (NumberFormatException var4) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_INTEGER_ERROR, new String[]{strId});
        }

        return numId;
    }

    private void initLifecycleTemplate(BaseLineDO baseLineDO, String permissionName, String lifecycleTemplateId, String lifecycleTemplateName) {
        if (StringUtils.equals("创建", permissionName)) {
            if (StringUtils.isEmpty(lifecycleTemplateId) && StringUtils.isEmpty(lifecycleTemplateName)) {
                TypeDO typeDO = this.typlmTypeService.getLastTypeByName(baseLineDO.getOtype());
                if (Objects.isNull(typeDO)) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_TYPE_DOES_NOT_EXIS_OR_UNAVAILABLE_IN_THE_SYSTEM, new String[]{baseLineDO.getOtype()})));
                }

                TyplmBasedLifeStageVO lifeStageVO = this.typlmBasedRuleService.getFirstStageByCondition(typeDO.getOid(), baseLineDO.getContaineroid(), baseLineDO.getContainerotype());
                if (Objects.isNull(lifeStageVO) || Objects.isNull(lifeStageVO.getTemplateEntity())) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_TYPE_TYPEBASEDRULE_NOT_BIND_LIFECYCLETEMPLATE, new String[]{baseLineDO.getOtype()})));
                }

                baseLineDO.setLifecycletemplateoid(lifeStageVO.getTemplateEntity().getOid());
                baseLineDO.setLifecyclestagekey(lifeStageVO.getStagestate());
            } else {
                this.setBaselineLifecycleTemplate(baseLineDO, lifecycleTemplateId, lifecycleTemplateName);
            }

            baseLineDO.setLifecycletemplateotype("ty.inteplm.lifecycle.CTyLifecycleTemplate");
        }

        TyplmLoggerUtil.debug(log, () -> "initLifecycleTemplate ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
    }

    private void setBaselineLifecycleTemplate(BaseLineDO baseLineDO, String lifecycleTemplateId, String lifecycleTemplateName) {
        TyplmLoggerUtil.debug(log, () -> "setBaselineLifecycleTemplate ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        TyLifeCycleTemplateAndStageDTO lifeCycleTemplateAndStageDTO = this.typlmLifecycleTemplateService.getLifeCycleTemplateWithException(CommonUtil.stringToBigInteger(lifecycleTemplateId), lifecycleTemplateName);
        if (lifeCycleTemplateAndStageDTO.getLockstateinfo().equals("wrk")) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_IS_CHECKOUT_CANNOT_USED, new String[0]);
        }

        LifeCycleStageTemplateDO stage = this.typlmLifecycleStageTemplateService.queryFirstStageByTemplateOid(lifeCycleTemplateAndStageDTO.getLifeCycleTemplateOid());
        if (Objects.isNull(stage)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_FIRSTSTAGE_NOT_FOUND, new String[]{lifecycleTemplateId + "  " + lifecycleTemplateName})));
        } else {
            baseLineDO.setLifecycletemplateoid(lifeCycleTemplateAndStageDTO.getLifeCycleTemplateOid());
            baseLineDO.setLifecyclestagekey(stage.getStagestate());
            TyplmLoggerUtil.debug(log, () -> "setBaselineLifecycleTemplate <== baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        }
    }

    private void setContainerInfo(BaseLineDO baseLineDO, SubfolderDO subfolderDO, ContainerVO containerVO) {
        TyplmLoggerUtil.debug(log, () -> "setContainerInfo ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        if (ObjectUtils.isNotEmpty(subfolderDO)) {
            baseLineDO.setContaineroid(subfolderDO.getContaineroid());
            baseLineDO.setContainerotype(subfolderDO.getContainerotype());
            baseLineDO.setCabinetoid(subfolderDO.getCabinetoid());
            baseLineDO.setCabinetotype(subfolderDO.getCabinetotype());
            baseLineDO.setSubfolderoid(subfolderDO.getOid());
            baseLineDO.setSubfolderotype(subfolderDO.getOtype());
            baseLineDO.setDomainoid(subfolderDO.getDomainoid());
            baseLineDO.setDomainotype(subfolderDO.getDomainotype());
            baseLineDO.setFoldernameinfo(subfolderDO.getName());
        } else if (ObjectUtils.isNotEmpty(containerVO)) {
            baseLineDO.setContaineroid(CommonUtil.stringToBigIntegers(containerVO.getOid()));
            baseLineDO.setContainerotype(containerVO.getOtype());
            baseLineDO.setCabinetoid(CommonUtil.stringToBigIntegers(containerVO.getDefaultcabinetoid()));
            baseLineDO.setCabinetotype(containerVO.getDefaultcabinetotype());
            baseLineDO.setSubfolderoid(BigInteger.ZERO);
            baseLineDO.setDomainoid(CommonUtil.stringToBigIntegers(containerVO.getDefaultdomainoid()));
            baseLineDO.setDomainotype(containerVO.getDefaultdomainotype());
        } else {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_NOT_FOUND, new String[]{"subFolder"});
        }

        TyplmLoggerUtil.debug(log, () -> "setContainerInfo ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
    }

    private BaseLineDO setBaseLineDO(BaseLineDTO baseLineDTO) {
        BaseLineDO baseLineDO = new BaseLineDO();
        baseLineDO.setOid(this.snowflakeIdComponent.getInstance().nextId());
        TyplmEntityBaseUtil.fillCommonFieldForCreate(baseLineDO);
        baseLineDO.setAtgatestate(0L);
        baseLineDO.setOtype("ty.inteplm.baseline.CTyBaseLine");
        baseLineDO.setDirty(0L);
        baseLineDO.setCreatoroid(this.getUserIdByNameAndContext(baseLineDTO.getUserId()));
        baseLineDO.setCreatorotype(TyAccountContext.getUser().getOtype());
        baseLineDO.setTopobjectoid(BigInteger.ZERO);
        baseLineDO.setTeamidisnull(0L);
        baseLineDO.setTeamtemplateidisnull(0L);
        baseLineDO.setName(baseLineDTO.getName());
        baseLineDO.setBaselinenumber(baseLineDTO.getNumber());
        baseLineDO.setDescription(baseLineDTO.getDescription());
        if (ObjectUtils.isNotEmpty(baseLineDTO.getOwneroid())) {
            baseLineDO.setOwneroid(baseLineDTO.getOwneroid());
            baseLineDO.setOwnerotype("ty.inteplm.org.CTyUser");
        } else {
            baseLineDO.setOwneroid(this.getUserIdByNameAndContext(baseLineDTO.getUserId()));
            baseLineDO.setOwnerotype(TyAccountContext.getUser().getOtype());
        }

        baseLineDO.setTypeoid(baseLineDTO.getTypeOid());
        baseLineDO.setTypeotype(baseLineDTO.getTypeOtype());
        baseLineDO.setSecuritylabels(baseLineDTO.getSecuritylabels());
        TyplmLoggerUtil.debug(log, () -> "setBaseLineDO ==> baseLineDTO =【{}】,baseLineDO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(baseLineDO)});
        return baseLineDO;
    }

    private BigInteger getUserIdByNameAndContext(String userName) {
        BigInteger userId = TyAccountContext.getUser().getOid();
        if (StringUtils.isNotBlank(userName)) {
            UserDO userDO = this.typlmUserService.queryUserByName(userName);
            if (Objects.isNull(userDO)) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_USER_NOT_FOUND, new String[]{userName})));
            }

            userId = userDO.getOid();
        }

        return userId;
    }

    private int insertFolderMemberLink(BaseLineDO baseLineDO) {
        TyplmLoggerUtil.debug(log, () -> "insertFolderMemberLink ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        FolderMemberLinkDO folderMemberLinkDO = new FolderMemberLinkDO();
        folderMemberLinkDO.setOid(this.snowflakeIdComponent.getInstance().nextId());
        folderMemberLinkDO.setOtype("ty.inteplm.folder.CTyFolderMemberLink");
        folderMemberLinkDO.setCreatoroid(TyAccountContext.getUser().getOid());
        folderMemberLinkDO.setCreatorotype(TyAccountContext.getUser().getOtype());
        folderMemberLinkDO.setBoid(baseLineDO.getOid());
        folderMemberLinkDO.setBotype("ty.inteplm.baseline.CTyBaseLine");
        TyplmEntityBaseUtil.fillCommonFieldForCreate(folderMemberLinkDO);
        if (!Objects.isNull(baseLineDO.getSubfolderoid()) && !Objects.equals(baseLineDO.getSubfolderoid(), BigInteger.ZERO)) {
            folderMemberLinkDO.setAoid(baseLineDO.getSubfolderoid());
            folderMemberLinkDO.setAotype("ty.inteplm.folder.CTySubFolder");
        } else {
            folderMemberLinkDO.setAoid(baseLineDO.getCabinetoid());
            folderMemberLinkDO.setAotype("ty.inteplm.folder.CTyCabinet");
        }

        TyplmLoggerUtil.debug(log, () -> "insertFolderMemberLink ==> folderMemberLinkDO =【{}】", () -> new Object[]{JSON.toJSONString(folderMemberLinkDO)});
        return this.typlmFolderMemberLinkService.insertFolderMemberLink(folderMemberLinkDO);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public int updateBaseLine(BaseLineDTO baseLineDTO) {
        if (!Objects.isNull(baseLineDTO) && !StringUtils.isEmpty(baseLineDTO.getOid())) {
            TyplmLoggerUtil.debug(log, () -> "updateBaseLine ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
            BigInteger baselineId = this.strId2NumberId(baseLineDTO.getOid());
            BaseLineDO baseLineDO = (BaseLineDO)this.typlmBaseLineMapper.selectByPrimaryKey(baselineId);
            if (Objects.isNull(baseLineDO)) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"Baseline ：" + baseLineDTO.getOid()})));
            } else {
                if (baseLineDO.getIslocked() != null && baseLineDO.getIslocked() == 1L) {
                    UserDO userDO = CommonUtil.getUser();
                    if (baseLineDO.getLockeroid() != null && Objects.equals(baseLineDO.getLockeroid(), userDO.getOid())) {
                        this.permissionCheck(baseLineDO, "读取_修改");
                    } else {
                        this.permissionCheck(baseLineDO, "读取_修改_管理");
                    }
                } else {
                    this.permissionCheck(baseLineDO, "读取_修改");
                }

                this.setUpdateBaseLineDO(baseLineDO, baseLineDTO);
                this.setLockAndStrict(baseLineDO, baseLineDTO);
                if (StringUtils.isNotBlank(baseLineDTO.getSecuritylabels())) {
                    baseLineDO.setSecuritylabels(baseLineDTO.getSecuritylabels());
                }

                TyplmLoggerUtil.debug(log, () -> "updateBaseLine ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
                this.typlmBaseLineMapper.updateByPrimaryKey(baseLineDO);
                Map<String, List<String>> ibaAttributeMap = baseLineDTO.getIbaAttributeMap();
                TyplmLoggerUtil.debug(log, () -> "updateBaseLine ==> ibaAttributeMap =【{}】", () -> new Object[]{JSON.toJSONString(ibaAttributeMap)});
                if (ObjectUtils.isNotEmpty(ibaAttributeMap)) {
                    this.typlmAttributeValueService.saveIBAbyMap(baseLineDTO.getIbaAttributeMap(), baseLineDO, false);
                }

                return 1;
            }
        } else {
            throw BaseLineErrorCodeEnum.BASELINE_PARAM_NO_ERROR.getException(new Object[0]);
        }
    }

    private void permissionCheck(BaseLineDO baseLineDO, String permission) {
        List<TyBaseObject> objects = new ArrayList();
        objects.add(baseLineDO);
        TyplmLoggerUtil.debug(log, () -> "permissionCheck ==> baseLineDO =【{}】,permission=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO), permission});
        this.typlmPermissionsUtil.checkObjectPermissionList(TyAccountContext.getUser(), objects, permission);
    }

    private String compareList(List<BigInteger> baseLineIds, List<BaseLineDO> baseLineDOList) {
        TyplmLoggerUtil.debug(log, () -> "compareList ==> baseLineIds =【{}】,baseLineDOList=【{}】", () -> new Object[]{JSON.toJSONString(baseLineIds), JSON.toJSONString(baseLineDOList)});
        return (String)baseLineIds.stream().filter((id) -> !((List)baseLineDOList.stream().map(BaseLineDO::getOid).collect(Collectors.toList())).contains(id)).map(BigInteger::toString).collect(Collectors.joining(","));
    }

    private List<BaseLineDO> metaBatchQueryListByParams(Collection<BigInteger> baseLineIds, Map<String, Object> equalParams) {
        TyplmLoggerUtil.debug(log, () -> "metaBatchQueryListByParams ==> baseLineIds =【{}】,equalParams=【{}】", () -> new Object[]{JSON.toJSONString(baseLineIds), JSON.toJSONString(equalParams)});
        return BatchQueryHelper.queryExampleColumnIn(baseLineIds, equalParams, BaseLineDO.class, "oid", this.typlmBaseLineMapper);
    }

    private void metaBatchDeleteByParams(Collection<BigInteger> baseLineIds, Map<String, Object> equalParams) {
        TyplmLoggerUtil.debug(log, () -> "metaBatchDeleteByParams ==> baseLineIds =【{}】,equalParams=【{}】", () -> new Object[]{JSON.toJSONString(baseLineIds), JSON.toJSONString(equalParams)});
        BatchQueryHelper.deleteExampleColumnIn(baseLineIds, BaseLineDO.class, "oid", this.typlmBaseLineMapper, equalParams);
    }

    public int deleteBaseLineByOids(List<String> ids) {
        TyplmLoggerUtil.debug(log, () -> "deleteBaseLineByOids ==> ids =【{}】", () -> new Object[]{JSON.toJSONString(ids)});
        if (!CollectionUtils.isEmpty(ids)) {
            if (ids.size() > 20) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_COMMON_BATCHNUM_EXCEED, new String[]{"20"});
            }

            List<BigInteger> baseLineIds = Lists.newArrayList();
            ids.stream().distinct().forEach((id) -> baseLineIds.add(this.strId2NumberId(id)));
            if (ObjectUtils.isEmpty(TyAccountContext.getUser())) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_USER_NOT_FOUND, new String[]{TyAccountContext.getUser() + ""});
            }

            Map<String, Object> equalParams = new HashMap();
            equalParams.put("otype", "ty.inteplm.baseline.CTyBaseLine");
            List<BaseLineDO> baseLineDOList = BatchQueryHelper.batchSplitQuery(baseLineIds, equalParams, this::metaBatchQueryListByParams);
            if (!CollectionUtils.isEmpty(baseLineDOList)) {
                String result = this.compareList(baseLineIds, baseLineDOList);
                if (!Strings.isNullOrEmpty(result)) {
                    TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"Baseline :" + result});
                }
            } else {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"Baseline :" + baseLineIds});
            }

            List<TyBaseObject> objects = new ArrayList();
            objects.addAll(baseLineDOList);
            this.typlmPermissionsUtil.checkObjectPermissionList(TyAccountContext.getUser(), objects, "读取_删除");
            this.typlmFolderMemberLinkService.batchDeleteFolderMemberLink(baseLineIds, "ty.inteplm.baseline.CTyBaseLine");
            this.deleteExamplelife(baseLineIds);
            this.typlmBaseLineMemberService.batchDeleteBaseLineMember(baseLineIds);
            this.typlmCommonEntityService.deletePositionMovementHistory(baseLineIds, "ty.inteplm.baseline.CTyBaseLine");
            BatchQueryHelper.batchSplitDelete(baseLineIds, equalParams, this::metaBatchDeleteByParams);
            return baseLineIds.size();
        } else {
            return 0;
        }
    }

    public List<BaseLineDO> batchQueryBaselineByBoids(List<BigInteger> bOidList, String bOtype) {
        TyplmLoggerUtil.debug(log, () -> "batchQueryBaselineByBoids ==> bOidList =【{}】,bOtype=【{}】", () -> new Object[]{JSON.toJSONString(bOidList), bOtype});
        return BatchQueryHelper.batchSplitQuery(bOidList, (list) -> this.typlmBaseLineMapper.batchQueryBaseLineByBoid(new ArrayList(list), bOtype));
    }

    public BaseLineDO queryBaseLineByNumber(String number) {
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineByNumber ==> number =【{}】", () -> new Object[]{number});
        Example example = new Example(BaseLineDO.class, true, true);
        example.createCriteria().andEqualTo("baselinenumber", number);
        List<BaseLineDO> baseLineList = this.typlmBaseLineMapper.selectByExample(example);
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineByNumber ==> baseLineList =【{}】", () -> new Object[]{JSON.toJSONString(baseLineList)});
        return CollectionUtils.isEmpty(baseLineList) ? NULL : (BaseLineDO)baseLineList.get(0);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public List<String> createBaseLineAndAssociateObjects(BaseLineDTO baseLineDTO, List<ObjectVO> objectArray) {
        TyplmLoggerUtil.debug(log, () -> "createBaseLineAndAssociateObjects ==> baseLineDTO =【{}】,objectArray=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(objectArray)});
        BigInteger baseLineId = this.insertBaseLine(baseLineDTO);
        this.typlmBaseLineMemberService.createBaselineWithObjects(baseLineId + "", objectArray, TyAccountContext.getUser().getOid() + "");
        return Collections.singletonList(baseLineId + "");
    }

    public List<BaseLineDO> queryBaseLineByoids(List<String> oids) {
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineByoids ==> oids =【{}】", () -> new Object[]{JSON.toJSONString(oids)});
        List<BigInteger> oidList = new ArrayList();

        for(String str : oids) {
            if (StringUtils.isNotEmpty(str)) {
                oidList.add(new BigInteger(str));
            }
        }

        if (CollectionUtils.isEmpty(oidList)) {
            return new ArrayList();
        } else {
            TyplmLoggerUtil.debug(log, () -> "metaSelectByOids ==> oidList =【{}】", () -> new Object[]{JSON.toJSONString(oidList)});
            return BatchQueryHelper.batchSplitQuery(oidList, this::metaSelectByOids);
        }
    }

    private List<BaseLineDO> metaSelectByOids(Collection<BigInteger> oidList) {
        TyplmLoggerUtil.debug(log, () -> "metaSelectByOids ==> oidList =【{}】", () -> new Object[]{JSON.toJSONString(oidList)});
        return BatchQueryHelper.queryExampleColumnIn(oidList, BaseLineDO.class, "oid", this.typlmBaseLineMapper);
    }

    public List<BaseLineDO> queryAccessBaseLineByOids(List<String> oids) {
        List<BigInteger> oidList = new ArrayList();
        TyplmLoggerUtil.debug(log, () -> "queryAccessBaseLineByOids ==> oids =【{}】", () -> new Object[]{JSON.toJSONString(oids)});

        for(String str : oids) {
            if (StringUtils.isNotEmpty(str)) {
                oidList.add(new BigInteger(str));
            }
        }

        return BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMapper.queryAccessBaseLineByOids(new ArrayList(list)));
    }

    private int deleteExamplelife(List<BigInteger> baseLineIds) {
        TyplmLoggerUtil.debug(log, () -> "deleteExamplelife ==> baseLineIds =【{}】", () -> new Object[]{JSON.toJSONString(baseLineIds)});
        List<BigInteger> lifeList = this.typlmObjectHistoryService.batchDeleteObjectHistory(baseLineIds);
        int result = 0;
        if (CollUtil.isEmpty(lifeList)) {
            return result;
        } else {
            for(List<BigInteger> piece : CollUtil.split(lifeList, 800)) {
                Example examplelife = new Example(LifeCycleHistoryDO.class, true, true);
                Example.Criteria criteria = examplelife.createCriteria();
                criteria.andIn("oid", piece);
                criteria.andEqualTo("otype", "ty.inteplm.lifecycle.CTyLifecycleHistory");
                result += this.typlmLifeCycleHistoryService.deleteLifecycleHistoryByExample(examplelife);
            }

            int finalResult = result;
            TyplmLoggerUtil.debug(log, () -> "deleteExamplelife ==> result =【{}】", () -> new Object[]{JSON.toJSONString(
                    finalResult)});
            return result;
        }
    }

    private BaseLineDO setUpdateBaseLineDO(BaseLineDO baseLineDO, BaseLineDTO baseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "setUpdateBaseLineDO ==> baseLineDO =【{}】,baseLineDTO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO), JSON.toJSONString(baseLineDTO)});
        if (ObjectUtils.isNotEmpty(baseLineDTO) && ObjectUtils.isNotEmpty(baseLineDO)) {
            if (baseLineDTO.getDescription() != null) {
                baseLineDO.setDescription(baseLineDTO.getDescription());
            }

            TyplmEntityBaseUtil.fillCommonFieldForUpdate(baseLineDO);
        }

        TyplmLoggerUtil.debug(log, () -> "setUpdateBaseLineDO ==>baseLineDO  =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        return baseLineDO;
    }

    private BaseLineDO setLockAndStrict(BaseLineDO baseLineDO, BaseLineDTO baseLineDTO) {
        TyplmLoggerUtil.debug(log, () -> "setLockAndStrict ==> baseLineDO =【{}】,baseLineDTO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO), JSON.toJSONString(baseLineDTO)});
        if (baseLineDTO.getIsProtected() != null) {
            if ("Y".equals(baseLineDTO.getIsProtected().toUpperCase(Locale.ENGLISH))) {
                baseLineDO.setStrict(1L);
            } else {
                baseLineDO.setStrict(0L);
            }
        }

        if (baseLineDTO.getLock() != null) {
            Date firstDate = new Date();
            if ("Y".equals(baseLineDTO.getLock().toUpperCase(Locale.ENGLISH))) {
                if (Objects.isNull(baseLineDO.getIslocked()) || baseLineDO.getIslocked() != 1L) {
                    baseLineDO.setIslocked(1L);
                    baseLineDO.setLockerotype(TyAccountContext.getUser().getOtype());
                    baseLineDO.setLockeroid(this.getUserIdByNameAndContext(baseLineDTO.getUserId()));
                    baseLineDO.setLockdate(firstDate);
                }
            } else {
                baseLineDO.setIslocked(0L);
                baseLineDO.setLockerotype((String)null);
                baseLineDO.setLockeroid((BigInteger)null);
                baseLineDO.setLockdate((Date)null);
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setLockAndStrict ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        return baseLineDO;
    }

    public void batchUpdateLifecycleManagedKey(List updateObjectLifecycleList) {
        TyplmLoggerUtil.debug(log, () -> "batchUpdateLifecycleManagedKey ==> updateObjectLifecycleList =【{}】", () -> new Object[]{JSON.toJSONString(updateObjectLifecycleList)});
        this.typlmBaseLineMapper.batchUpdateLifecyclestagekey(updateObjectLifecycleList);
    }

    public List<CTyEntityBaseDO> getItemsByIDList(List<BigInteger> idList) {
        TyplmLoggerUtil.debug(log, () -> "getItemsByIDList ==> idList =【{}】", () -> new Object[]{JSON.toJSONString(idList)});
        return new ArrayList(BatchQueryHelper.batchSplitQuery(idList, this::metaSelectByOids));
    }

    public List<BigInteger> batchCreateBaseLine(List<BaseLineDTO> baseLineDTOList) {
        TyplmLoggerUtil.debug(log, () -> "batchCreateBaseLine ==> baseLineDTOList =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTOList)});
        if (CollUtil.isNotEmpty(baseLineDTOList)) {
            List<BigInteger> typeOidList = (List)baseLineDTOList.stream().map(BaseLineDTO::getTypeOid).filter(Objects::nonNull).collect(Collectors.toList());
            if (CollUtil.isNotEmpty(typeOidList)) {
                this.typlmTypeService.checkTypeInstance(typeOidList);
            }
        }

        List<BigInteger> result = new ArrayList();
        HashMap<String, Object> codeChangeData = new HashMap();
        this.setNumber(baseLineDTOList, codeChangeData);
        TyplmLoggerUtil.debug(log, () -> "batchCreateBaseLine 设置分类编码==> baseLineDTOList =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTOList)});
        Map<String, Object> requestContext = RequestContext.currentContext();
        baseLineDTOList.parallelStream().forEach((item) -> {
            RequestContext.attachContext(requestContext);
            result.add(this.insertBaseLine(item));
        });
        TyplmLoggerUtil.debug(log, () -> "batchCreateBaseLine ==> codeChangeData =【{}】", () -> new Object[]{JSON.toJSONString(codeChangeData)});
        if (CollUtil.isNotEmpty(codeChangeData)) {
            this.typlmCodeService.saveCodeChangeData(codeChangeData);
        }

        return result;
    }

    private void queryAndSetCreateLifecycle(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO, TypeDO typeDO) {
        TyplmLoggerUtil.debug(log, () -> "queryAndSetCreateLifecycle ==> baseLineDTO =【{}】,baseLineDO=【{}】,typeDO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(baseLineDO), JSON.toJSONString(typeDO)});
        if (StringUtils.isEmpty(baseLineDTO.getLifecycleTemplateName())) {
            this.resetLifecylceTempByBasedRule(baseLineDTO, baseLineDO, typeDO);
        } else {
            LifeCycleTemplateDO lifeCycleTemplateDO = this.typlmLifecycleTemplateService.queryLifecycleNotWrkByName(baseLineDTO.getLifecycleTemplateName());
            TyplmLoggerUtil.debug(log, () -> "queryAndSetCreateLifecycle ==> lifeCycleTemplateDO =【{}】", () -> new Object[]{JSON.toJSONString(lifeCycleTemplateDO)});
            if (!org.springframework.util.ObjectUtils.isEmpty(lifeCycleTemplateDO)) {
                baseLineDTO.setLifecycleTemplateOid(lifeCycleTemplateDO.getOid().toString());
                this.resetLifecylceTempAndWorkFlow(baseLineDTO, baseLineDO);
            } else {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_NOT_FOUND, new String[]{baseLineDTO.getLifecycleTemplateName()});
            }

        }
    }

    private void resetLifecylceTempByBasedRule(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO, TypeDO typeDO) {
        TyplmLoggerUtil.debug(log, () -> "resetLifecylceTempByBasedRule ==> baseLineDTO =【{}】,baseLineDO=【{}】,typeDO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(baseLineDO), JSON.toJSONString(typeDO)});
        TyplmBaseRuleTypeDTO baseRuleTypeDTO = new TyplmBaseRuleTypeDTO(typeDO.getOid(), typeDO.getOtype(), typeDO.getParentnodeoid(), typeDO.getBranchid(), typeDO.getName());
        TyplmLoggerUtil.debug(log, () -> "resetLifecylceTempByBasedRule ==> baseRuleTypeDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseRuleTypeDTO)});
        TyplmBasedLifeStageVO typeBasedLifeStageVO = this.typlmBasedRuleService.getFirstStageByCondition(baseRuleTypeDTO, CommonUtil.stringToBigIntegers(baseLineDTO.getContainerId()), baseLineDTO.getContainerType());
        TyplmLoggerUtil.debug(log, () -> "resetLifecylceTempByBasedRule ==> typeBasedLifeStageVO =【{}】", () -> new Object[]{JSON.toJSONString(typeBasedLifeStageVO)});
        IdentifierEntity lifeCycleStageTemplateDO = IDENTIFIER_NULL;
        IdentifierEntity lifeCycleTemplateDO = IDENTIFIER_NULL;
        if (Objects.nonNull(typeBasedLifeStageVO)) {
            lifeCycleStageTemplateDO = typeBasedLifeStageVO.getStageTemplateEntity();
            lifeCycleTemplateDO = typeBasedLifeStageVO.getTemplateEntity();
        }

        if (org.springframework.util.ObjectUtils.isEmpty(lifeCycleTemplateDO)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_TYPE_TYPEBASEDRULE_NOT_BIND_LIFECYCLETEMPLATE, new String[]{typeDO.getName()});
        } else {
            baseLineDO.setLifecycletemplateoid(lifeCycleTemplateDO.getOid());
            baseLineDO.setLifecycletemplateotype(lifeCycleTemplateDO.getOtype());
            if (ObjectUtils.isNotEmpty(baseLineDTO.getLifecyclestagekey())) {
                TyLifeCycleTemplateAndStageDTO templateAndStatusDTO = this.typlmLifecycleTemplateService.getTemplateAndStageById(baseLineDO.getLifecycletemplateoid());
                this.judgeAndSetLifecycleState(baseLineDTO, baseLineDO, templateAndStatusDTO);
            } else if (lifeCycleStageTemplateDO != null) {
                baseLineDO.setLifecyclestagekey(typeBasedLifeStageVO.getStagestate() == null ? "INWORK" : typeBasedLifeStageVO.getStagestate());
            }

        }
    }

    private void resetLifecylceTempAndWorkFlow(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO) {
        TyplmLoggerUtil.debug(log, () -> "resetLifecylceTempAndWorkFlow ==> baseLineDTO =【{}】,baseLineDO=【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO), JSON.toJSONString(baseLineDO)});
        if (ObjectUtils.isNotEmpty(baseLineDTO.getLifecycleTemplateOid())) {
            baseLineDO.setLifecycletemplateoid(new BigInteger(baseLineDTO.getLifecycleTemplateOid()));
        }

        TyLifeCycleTemplateAndStageDTO templateAndStatusDTO = this.typlmLifecycleTemplateService.getTemplateAndStageById(baseLineDO.getLifecycletemplateoid());
        if (ObjectUtils.isEmpty(templateAndStatusDTO)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_NOT_FOUND, new String[]{baseLineDTO.getLifecycleTemplateOid()});
        }

        this.checkLifeCycleTemplate(templateAndStatusDTO);
        if (ObjectUtils.isNotEmpty(baseLineDTO.getLifecyclestagekey())) {
            this.judgeAndSetLifecycleState(baseLineDTO, baseLineDO, templateAndStatusDTO);
        } else {
            if (ObjectUtils.isEmpty(templateAndStatusDTO.getFirstStageCode())) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_FIRSTSTAGE_NOT_FOUND, new String[]{templateAndStatusDTO.getLifeCycleTemplateName()});
            }

            baseLineDO.setLifecyclestagekey(templateAndStatusDTO.getFirstStageCode());
        }

        TyplmLoggerUtil.debug(log, () -> "resetLifecylceTempAndWorkFlow ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
    }

    private void checkLifeCycleTemplate(TyLifeCycleTemplateAndStageDTO templateAndStatusDTO) {
        TyplmLoggerUtil.debug(log, () -> "checkLifeCycleTemplate ==> templateAndStatusDTO =【{}】", () -> new Object[]{JSON.toJSONString(templateAndStatusDTO)});
        Long disabled = templateAndStatusDTO.getDisabled();
        if (ObjectUtils.isNotEmpty(disabled) && disabled == 1L) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_DISABLED, new String[]{templateAndStatusDTO.getLifeCycleTemplateName()});
        }

    }

    private void judgeAndSetLifecycleState(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO, TyLifeCycleTemplateAndStageDTO templateAndStatusDTO) {
        TyplmLoggerUtil.debug(log, () -> "judgeAndSetLifecycleState ==> templateAndStatusDTO =【{}】", () -> new Object[]{JSON.toJSONString(templateAndStatusDTO)});
        List<String> stagestateList = templateAndStatusDTO.getStagestateList();
        if (ObjectUtils.isEmpty(stagestateList)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_FIRSTSTAGE_NOT_FOUND, new String[]{templateAndStatusDTO.getLifeCycleTemplateName()});
        }

        if (!stagestateList.contains(baseLineDTO.getLifecyclestagekey())) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_LIFECYCLETEMPLATE_NOT_VALID_STATE, new String[]{baseLineDTO.getLifecyclestagekey(), templateAndStatusDTO.getLifeCycleTemplateName()});
        }

        baseLineDO.setLifecyclestagekey(baseLineDTO.getLifecyclestagekey());
        TyplmLoggerUtil.debug(log, () -> "judgeAndSetLifecycleState ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
    }

    private TypeDO setType(BaseLineDTO baseLineDTO, BaseLineDO baseLineDO) {
        if (StringUtil.isNotEmpty(baseLineDTO.getTypeOid())) {
            TypeDO typeDO = this.typlmTypeService.queryTypeByOID(baseLineDTO.getTypeOid());
            if (org.springframework.util.ObjectUtils.isEmpty(typeDO)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_TYPE_DOES_NOT_EXIS_OR_UNAVAILABLE_IN_THE_SYSTEM, new String[]{String.valueOf(baseLineDTO.getTypeOid())});
            } else {
                if (typeDO.getMarkfordelete() == 1L) {
                    TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_TYPE_DOES_NOT_EXIS_OR_UNAVAILABLE_IN_THE_SYSTEM, new String[]{String.valueOf(baseLineDTO.getTypeOid())});
                }

                baseLineDO.setTypeoid(baseLineDTO.getTypeOid());
                baseLineDO.setTypeotype(baseLineDTO.getTypeOtype());
            }

            return typeDO;
        } else {
            return null;
        }
    }

    private void setNumber(List<BaseLineDTO> insertDTOList, HashMap<String, Object> changeData) {
        TyplmLoggerUtil.debug(log, () -> "setNumber ==> insertDTOList =【{}】", () -> new Object[]{JSON.toJSONString(insertDTOList)});
        HashMap<String, TyplmBaseRuleBoundedObjDTO> baseRuleInfoData = new HashMap();
        List<TyplmBatchCodeParam> paramList = new ArrayList();

        for(BaseLineDTO insertDto : insertDTOList) {
            String key = insertDto.getTypeOid() + "-" + insertDto.getContainerId() + "-" + insertDto.getContainerType();
            TyplmBaseRuleBoundedObjDTO baseRuleBoundedObjDTO;
            if (baseRuleInfoData.containsKey(key)) {
                baseRuleBoundedObjDTO = (TyplmBaseRuleBoundedObjDTO)baseRuleInfoData.get(key);
            } else {
                baseRuleBoundedObjDTO = this.typlmBasedRuleService.getBaseRuleBoundedObjInfo(insertDto.getTypeOid(), new BigInteger(insertDto.getContainerId()), insertDto.getContainerType());
                baseRuleInfoData.put(key, baseRuleBoundedObjDTO);
            }

            if (ObjectUtil.isNotEmpty(baseRuleBoundedObjDTO) && ObjectUtil.isNotEmpty(baseRuleBoundedObjDTO.getNumberType()) && baseRuleBoundedObjDTO.getNumberType().compareTo(1) == 0) {
                if (Objects.isNull(insertDto.getClassId())) {
                    throw CodeErrorCodeEnum.CODE_CLASS_DATA_NO_ERROR.getException(new Object[0]);
                }

                IdentifierEntity classIdentifier = new IdentifierEntity();
                classIdentifier.setOid(new BigInteger(insertDto.getClassId()));
                classIdentifier.setOtype("ty.inteplm.type.CTyClassification");
                this.addBatchCodeParam(key, classIdentifier, paramList);
            }
        }

        if (CollUtil.isNotEmpty(paramList)) {
            TyplmLoggerUtil.debug(log, () -> "setNumber-batchGenerateCode ==> paramList =【{}】", () -> new Object[]{JSON.toJSONString(paramList)});
            this.typlmCodeService.batchGenerateCode(paramList, changeData);
        }

        TyplmLoggerUtil.debug(log, () -> "setNumber将编码更新至对象上 ==> insertDTOList =【{}】,paramList=【{}}", () -> new Object[]{JSON.toJSONString(insertDTOList), JSON.toJSONString(paramList)});
        this.updateNumber(insertDTOList, paramList);
    }

    private void updateNumber(List<BaseLineDTO> insertDTOList, List<TyplmBatchCodeParam> paramList) {
        for(BaseLineDTO insertDto : insertDTOList) {
            if (!Objects.isNull(insertDto.getClassId())) {
                String key = insertDto.getTypeOid() + "-" + insertDto.getContainerId() + "-" + insertDto.getContainerType();
                List<TyplmBatchCodeParam> typlmBatchCodeParamList = (List)paramList.stream().filter((item) -> item.getKey().equals(key) && ObjectUtils.isNotEmpty(item.getClassEntity().getOid()) && ObjectUtils.isNotEmpty(insertDto.getClassId()) && item.getClassEntity().getOid().compareTo(new BigInteger(insertDto.getClassId())) == 0).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(typlmBatchCodeParamList) && CollUtil.isNotEmpty(((TyplmBatchCodeParam)typlmBatchCodeParamList.get(0)).getCodes())) {
                    String code = (String)((TyplmBatchCodeParam)typlmBatchCodeParamList.get(0)).getCodes().get(0);
                    insertDto.setNumber(code);
                    ((TyplmBatchCodeParam)typlmBatchCodeParamList.get(0)).getCodes().remove(code);
                }
            }
        }

        TyplmLoggerUtil.debug(log, () -> "updateNumber <== insertDTOList =【{}】,paramList=【{}】", () -> new Object[]{JSON.toJSONString(insertDTOList), JSON.toJSONString(paramList)});
    }

    public void addBatchCodeParam(String key, IdentifierEntity classEntity, List<TyplmBatchCodeParam> paramList) {
        if (!StringUtils.isEmpty(key)) {
            if (CollUtil.isEmpty(paramList)) {
                TyplmBatchCodeParam param = new TyplmBatchCodeParam();
                param.setCount(1);
                param.setClassEntity(classEntity);
                param.setKey(key);
                paramList.add(param);
            } else {
                List<TyplmBatchCodeParam> typlmBatchCodeParamList = (List)paramList.stream().filter((item) -> item.getKey().equals(key) && ObjectUtils.isNotEmpty(item.getClassEntity().getOid()) && ObjectUtils.isNotEmpty(classEntity.getOid()) && item.getClassEntity().getOid().compareTo(classEntity.getOid()) == 0).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(typlmBatchCodeParamList)) {
                    ((TyplmBatchCodeParam)typlmBatchCodeParamList.get(0)).setCount(((TyplmBatchCodeParam)typlmBatchCodeParamList.get(0)).getCount() + 1);
                } else {
                    TyplmBatchCodeParam param = new TyplmBatchCodeParam();
                    param.setCount(1);
                    param.setClassEntity(classEntity);
                    param.setKey(key);
                    paramList.add(param);
                }
            }

            TyplmLoggerUtil.debug(log, () -> "addBatchCodeParam ==> paramList =【{}】", () -> new Object[]{JSON.toJSONString(paramList)});
        }
    }

    public BaseLineDO getInfoByOid(BigInteger oid) {
        TyplmLoggerUtil.debug(log, () -> "getInfoByOid ==> oid =【{}】", () -> new Object[]{JSON.toJSONString(oid)});
        return (BaseLineDO)this.typlmBaseLineMapper.selectByPrimaryKey(oid);
    }

    public QueryBaseLineVO queryBaseLineDetail(BigInteger oid) {
        if (Objects.isNull(oid)) {
            throw BaseLineErrorCodeEnum.BASELINE_PARAM_NO_ERROR.getException(new Object[0]);
        } else {
            TyplmLoggerUtil.debug(log, () -> "queryBaseLineDetail ==>oid  =【{}】", () -> new Object[]{JSON.toJSONString(oid)});
            QueryBaseLineVO queryBaseLineVO = this.typlmBaseLineMapper.queryBaseLineDetail(oid, TyAccountContext.getLanguage());
            if (Objects.isNull(queryBaseLineVO)) {
                throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
            } else {
                this.getClassInfo(queryBaseLineVO);
                this.setUserLock(queryBaseLineVO, TyAccountContext.getUser());
                queryBaseLineVO.setType((String)FolderQueryConstant.QUERY_OTYPE_TO_TYPE_MAP.getOrDefault(queryBaseLineVO.getOtype(), queryBaseLineVO.getType()));
                BigInteger subfolderId = StringUtils.isEmpty(queryBaseLineVO.getFolderId()) ? BigInteger.ZERO : new BigInteger(queryBaseLineVO.getFolderId());
                Map<BigInteger, String> bigIntegerStringMap = this.typlmProductFolderService.recursiveQueryFolderPathByIdList(CollUtil.toList(new BigInteger[]{subfolderId}));
                queryBaseLineVO.setFolderPath((String)bigIntegerStringMap.get(subfolderId));
                Map<String, List<String>> ibaAttribute = this.typlmAttributeService.getIbaAttributeMap(oid, queryBaseLineVO.getOtype());
                queryBaseLineVO.setIbaAttributeMap(ibaAttribute);
                Map<String, String> lifeCycleStateCodeMap = this.typlmLocalePropertyValueService.queryLocaleValueByItem(CollUtil.toList(new String[]{queryBaseLineVO.getLifecyclestagekey()}), "LifeCycleState", TyCommonExtUtil.getFrontLanguage());
                queryBaseLineVO.setLifecycleStateName((String)lifeCycleStateCodeMap.getOrDefault(queryBaseLineVO.getLifecyclestagekey(), queryBaseLineVO.getLifecyclestagekey()));
                queryBaseLineVO.setLifecycleState(queryBaseLineVO.getLifecyclestagekey());
                TyplmLoggerUtil.debug(log, () -> "queryBaseLineDetail ==> queryBaseLineVO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVO)});
                return queryBaseLineVO;
            }
        }
    }

    private void setUserLock(QueryBaseLineVO queryBaseLineVO, UserDO userDO) {
        if (queryBaseLineVO.getLock().equalsIgnoreCase("Y") && Objects.nonNull(queryBaseLineVO.getLockeroid())) {
            if (queryBaseLineVO.getLockeroid().compareTo(userDO.getOid()) == 0) {
                queryBaseLineVO.setUserLock(1);
            } else {
                queryBaseLineVO.setUserLock(0);
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setUserLock ==> queryBaseLineVO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVO)});
    }

    private void getClassInfo(QueryBaseLineVO queryBaseLineVO) {
        Map<String, Object> classificationInfoMap = this.typlmClassificationService.queryClassNameByCondition(new BigInteger(queryBaseLineVO.getOid()), queryBaseLineVO.getOtype());
        if (MapUtil.isNotEmpty(classificationInfoMap)) {
            if (ObjectUtils.isNotEmpty(classificationInfoMap.get("oid"))) {
                queryBaseLineVO.setClassId(classificationInfoMap.get("oid").toString());
            }

            if (ObjectUtils.isNotEmpty(classificationInfoMap.get("displayName"))) {
                queryBaseLineVO.setClassDisplayName(classificationInfoMap.get("displayName").toString());
            }
        }

        TyplmLoggerUtil.debug(log, () -> "getClassInfo ==> queryBaseLineVO =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVO)});
    }

    public List<QueryBaseLineVO> queryBaseLineList(List<BigInteger> oidList) {
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineList ==> oidList =【{}】", () -> new Object[]{JSON.toJSONString(oidList)});
        List<QueryBaseLineVO> queryBaseLineVOList = BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMapper.queryBaseLineDetailList(new ArrayList(list), TyAccountContext.getLanguage()));
        List<BigInteger> subFolderIds = new ArrayList();
        UserDO userDO = TyAccountContext.getUser();

        for(QueryBaseLineVO queryBaseLineVO : queryBaseLineVOList) {
            if (queryBaseLineVO.getFolderId() != null) {
                subFolderIds.add(new BigInteger(queryBaseLineVO.getFolderId()));
            }
        }

        Map<BigInteger, String> bigIntegerStringMap = this.typlmProductFolderService.recursiveQueryFolderPathByIdList(subFolderIds);

        for(int i = 0; i < queryBaseLineVOList.size(); ++i) {
            QueryBaseLineVO queryBaseLineVO = (QueryBaseLineVO)queryBaseLineVOList.get(i);
            BigInteger subfolderId = StringUtils.isEmpty(queryBaseLineVO.getFolderId()) ? BigInteger.ZERO : new BigInteger(queryBaseLineVO.getFolderId());
            if (bigIntegerStringMap.containsKey(subfolderId)) {
                queryBaseLineVO.setFolderPath((String)bigIntegerStringMap.get(subfolderId));
            }

            this.setUserLock(queryBaseLineVO, userDO);
        }

        queryBaseLineVOList.forEach((item) -> {
            item.setType((String)FolderQueryConstant.QUERY_OTYPE_TO_TYPE_MAP.getOrDefault(item.getOtype(), item.getType()));
            item.setLifecycleState(item.getLifecyclestagekey());
        });
        List<String> lifeCycleStateCodeList = (List)queryBaseLineVOList.stream().map(QueryBaseLineVO::getLifecyclestagekey).collect(Collectors.toList());
        Map<String, String> lifeCycleStateCodeMap = this.typlmLocalePropertyValueService.queryLocaleValueByItem(lifeCycleStateCodeList, "LifeCycleState", TyCommonExtUtil.getFrontLanguage());
        queryBaseLineVOList.forEach((vo) -> vo.setLifecycleStateName((String)lifeCycleStateCodeMap.getOrDefault(vo.getLifecyclestagekey(), vo.getLifecyclestagekey())));
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineList ==> queryBaseLineVOList =【{}】", () -> new Object[]{JSON.toJSONString(queryBaseLineVOList)});
        return queryBaseLineVOList;
    }

    public BaseLineDO renameBaseline(BaseLineDTO baseLineDTO) {
        if (Objects.isNull(baseLineDTO)) {
            return null;
        } else {
            TyplmLoggerUtil.debug(log, () -> "renameBaseline ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
            BaseLineDO baseLineDO = (BaseLineDO)this.typlmBaseLineMapper.selectByPrimaryKey(this.strId2NumberId(baseLineDTO.getOid()));
            TyplmLoggerUtil.debug(log, () -> "renameBaseline ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            if (Objects.isNull(baseLineDO)) {
                return null;
            } else {
                BaseLineDO baseLineDOTemp = this.queryBaseLineByNumber(baseLineDTO.getNumber());
                if (Objects.nonNull(baseLineDOTemp) && baseLineDOTemp.getOid().compareTo(baseLineDO.getOid()) != 0) {
                    throw BaseLineErrorCodeEnum.BASELINE_PARAM_NUMBER_SAME_ERROR.getException(new Object[0]);
                } else {
                    baseLineDO.setBaselinenumber(baseLineDTO.getNumber());
                    TyplmEntityBaseUtil.fillCommonFieldForUpdate(baseLineDO);
                    this.typlmBaseLineMapper.updateByPrimaryKey(baseLineDO);
                    TyplmLoggerUtil.debug(log, () -> "renameBaseline-updateByPrimaryKey ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
                    return baseLineDO;
                }
            }
        }
    }

    public List<BaseLineDO> queryBaseLineListByNumber(String number) {
        TyplmLoggerUtil.debug(log, () -> "queryBaseLineListByNumber ==> number =【{}】", () -> new Object[]{JSON.toJSONString(number)});
        Example example = new Example(BaseLineDO.class, true, true);
        example.createCriteria().andEqualTo("baselinenumber", number);
        return this.typlmBaseLineMapper.selectByExample(example);
    }

    public Boolean updateState(BaseLineDTO baseLineDTO) {
        if (Objects.isNull(baseLineDTO)) {
            throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
        } else {
            TyplmLoggerUtil.debug(log, () -> "updateState ==> baseLineDTO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDTO)});
            BaseLineDO baseLineDO = (BaseLineDO)this.typlmBaseLineMapper.selectByPrimaryKey(this.strId2NumberId(baseLineDTO.getOid()));
            TyplmLoggerUtil.debug(log, () -> "updateState ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
            if (Objects.isNull(baseLineDO)) {
                throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
            } else if (StringUtils.isEmpty(baseLineDTO.getLifecyclestagekey())) {
                throw BaseLineErrorCodeEnum.BASELINE_PARAM_LIFECYCLE_NO_ERROR.getException(new Object[0]);
            } else {
                this.checkPermission(OperType.EDIT, baseLineDO);
                baseLineDO.setLifecyclestagekey(baseLineDTO.getLifecyclestagekey());
                TyplmEntityBaseUtil.fillCommonFieldForUpdate(baseLineDO);
                this.typlmBaseLineMapper.updateByPrimaryKey(baseLineDO);
                TyplmLoggerUtil.debug(log, () -> "updateState ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
                return true;
            }
        }
    }

    private void checkPermission(BaseLineConstant.OperType operType, BaseLineDO baseLineDO) {
        List<TyBaseObject> objects = new ArrayList();
        List<String> permissionList = new ArrayList();
        UserDO userDO = TyAccountContext.getUser();
        if (operType == OperType.LOCK) {
            permissionList.add("读取_修改");
            objects.add(baseLineDO);
        } else if (operType == OperType.UNLOCK || operType == OperType.EDIT) {
            if (baseLineDO.getIslocked().compareTo(1L) == 0) {
                if (Objects.nonNull(baseLineDO.getLockeroid()) && baseLineDO.getLockeroid().compareTo(userDO.getOid()) == 0) {
                    permissionList.add("读取_修改");
                } else {
                    permissionList.add("读取_修改_管理");
                }
            } else {
                permissionList.add("读取_修改");
            }

            objects.add(baseLineDO);
        }

        TyplmLoggerUtil.debug(log, () -> "checkPermission ==> objects =【{}】,permissionList=【{}】", () -> new Object[]{JSON.toJSONString(objects), JSON.toJSONString(permissionList)});
        this.typlmPermissionsUtil.checkObjectPermission(userDO, objects, permissionList);
    }

    public QueryBaseLineVO lockOrUnlockBaseLine(TyplmBaseLineParam parm) {
        TyplmLoggerUtil.debug(log, () -> "lockOrUnlockBaseLine ==> parm =【{}】", () -> new Object[]{JSON.toJSONString(parm)});
        BaseLineDO baseLineDO = this.getInfoByOid(parm.getInfo().getOid());
        TyplmLoggerUtil.debug(log, () -> "lockOrUnlockBaseLine-getInfoByOid ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        this.setLock(baseLineDO, parm.getLockType());
        TyplmEntityBaseUtil.fillCommonFieldForUpdate(baseLineDO);
        TyplmLoggerUtil.debug(log, () -> "lockOrUnlockBaseLine-updateByPrimaryKey ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        this.typlmBaseLineMapper.updateByPrimaryKey(baseLineDO);
        return this.queryBaseLineDetail(baseLineDO.getOid());
    }

    private BaseLineDO setLock(BaseLineDO baseLineDO, String lockType) {
        if (lockType != null) {
            Date firstDate = new Date();
            if ("Y".equals(lockType.toUpperCase(Locale.ENGLISH))) {
                this.checkPermission(OperType.LOCK, baseLineDO);
                baseLineDO.setIslocked(1L);
                baseLineDO.setLockerotype(TyAccountContext.getUser().getOtype());
                baseLineDO.setLockeroid(TyAccountContext.getUser().getOid());
                baseLineDO.setLockdate(firstDate);
            } else {
                this.checkPermission(OperType.UNLOCK, baseLineDO);
                baseLineDO.setIslocked(0L);
                baseLineDO.setLockerotype((String)null);
                baseLineDO.setLockeroid((BigInteger)null);
                baseLineDO.setLockdate((Date)null);
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setLock ==> baseLineDO =【{}】", () -> new Object[]{JSON.toJSONString(baseLineDO)});
        return baseLineDO;
    }

    public List<TyplmBaseLineComparisonResultsVO> compareBaseLineInfo(List<IdentifierEntity> objList) {
        TyplmLoggerUtil.debug(log, () -> "compareBaseLineInfo ==> objList =【{}】", () -> new Object[]{JSON.toJSONString(objList)});
        this.getBaselineMemberOtype();
        List<IdentifierEntity> baselineList = (List)objList.stream().filter((x) -> x.getOtype().equalsIgnoreCase("ty.inteplm.baseline.CTyBaseLine")).collect(Collectors.toList());
        if (CollUtil.isEmpty(baselineList)) {
            throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
        } else {
            CompareBaseLineReportDTO param = new CompareBaseLineReportDTO();
            param.setCompareInfoList(baselineList);
            TyplmLoggerUtil.debug(log, () -> "compareBaseLineInfo ==> param =【{}】", () -> new Object[]{JSON.toJSONString(param)});
            return this.getBaseLineCompareData(param);
        }
    }

    private List<TyplmBaseLineComparisonResultsVO> getBaseLineCompareData(CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "getBaseLineCompareData ==> param =【{}】", () -> new Object[]{JSON.toJSONString(param)});
        List<TyplmBaseLineComparisonResultsVO> resultsVOS = this.queryBaselineCompareInfo(param.getCompareInfoList());
        if (Boolean.TRUE.equals(param.getCompareObjectAttrs())) {
            this.getCompareObjData(param.getCompareInfoList(), resultsVOS);
        }

        this.setObjPerssmission(resultsVOS);
        this.compareBaseLineAttr(resultsVOS, param);
        if (Boolean.TRUE.equals(param.getCompareObjectAttrs())) {
            this.compareRefObj(resultsVOS);
        }

        List<TyplmBaseLineComparisonResultsVO> result = new ArrayList();

        for(int i = 0; i < param.getCompareInfoList().size(); ++i) {
            IdentifierEntity item = (IdentifierEntity)param.getCompareInfoList().get(i);
            TyplmBaseLineComparisonResultsVO itemInfoData = (TyplmBaseLineComparisonResultsVO)resultsVOS.stream().filter((itemInfo) -> item.getOid().compareTo(itemInfo.getOid()) == 0).findFirst().orElse(null);
            if (Objects.nonNull(itemInfoData)) {
                result.add(itemInfoData);
            }
        }

        TyplmLoggerUtil.debug(log, () -> "getBaseLineCompareData ==> result =【{}】", () -> new Object[]{JSON.toJSONString(result)});
        return result;
    }

    private List<TyplmBaseLineComparisonResultsVO> queryBaselineCompareInfo(List<IdentifierEntity> baselineList) {
        TyplmLoggerUtil.debug(log, () -> "queryBaselineCompareInfo ==> baselineList =【{}】", () -> new Object[]{JSON.toJSONString(baselineList)});
        List<BigInteger> oidList = (List)baselineList.stream().map(IdentifierEntity::getOid).distinct().collect(Collectors.toList());
        if (CollUtil.isEmpty(oidList)) {
            throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
        } else {
            List<TyplmBaseLineCompareSearchData> baseLineCompareData = BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMapper.queryBaseLineCompareData(new ArrayList(list), TyAccountContext.getLanguage()));
            if (CollUtil.isEmpty(baseLineCompareData)) {
                throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
            } else {
                TyplmLoggerUtil.debug(log, () -> "queryBaselineCompareInfo ==> baseLineCompareData =【{}】", () -> new Object[]{JSON.toJSONString(baseLineCompareData)});
                return this.compareDataToResultData(baseLineCompareData);
            }
        }
    }

    private void setObjPerssmission(List<TyplmBaseLineComparisonResultsVO> voList) {
        List<IdentifierEntity> objList = this.getIdentifierEntityByResultsVo(voList);
        HashMap<IdentifierEntity, Integer> canReadObjList = new HashMap();
        this.checkPerssmission(objList, canReadObjList);
        this.setPerssmission(canReadObjList, voList);
        TyplmLoggerUtil.debug(log, () -> "setObjPerssmission ==> voList =【{}】", () -> new Object[]{JSON.toJSONString(voList)});
    }

    private void checkPerssmission(List<IdentifierEntity> objList, HashMap<IdentifierEntity, Integer> canReadObjList) {
        List<TyBaseObject> objects = new ArrayList();
        List<String> permissions = new ArrayList();
        String refObjPermission = "读取";

        for(CTyEntityBaseDO item : CommonUtil.getEntityListIgnoreNotExist(objList)) {
            permissions.add(refObjPermission);
            objects.add(item);
        }

        List<AccessBatchDTO> accessBatchDTOS = this.typlmAccessJudgeService.checkAccessByObjectId(objects, TyAccountContext.getUser(), permissions);
        accessBatchDTOS.forEach((itemx) -> {
            IdentifierEntity identifier = new IdentifierEntity();
            identifier.setOid(new BigInteger(itemx.getObjectoid()));
            identifier.setOtype(itemx.getObjectotype());
            if ("N".equals(itemx.getIsAuthorized())) {
                canReadObjList.put(identifier, 0);
            } else {
                canReadObjList.put(identifier, 1);
            }

        });
        TyplmLoggerUtil.debug(log, () -> "checkPerssmission ==> objList =【{}】,canReadObjList=【{}】", () -> new Object[]{JSON.toJSONString(objList), JSON.toJSONString(canReadObjList)});
    }

    private List<IdentifierEntity> getIdentifierEntityByResultsVo(List<TyplmBaseLineComparisonResultsVO> voList) {
        List<IdentifierEntity> resultData = new ArrayList();

        for(TyplmBaseLineComparisonResultsVO item : voList) {
            IdentifierEntity identifier = new IdentifierEntity();
            identifier.setOid(item.getOid());
            identifier.setOtype(item.getOtype());
            resultData.add(identifier);
            if (CollUtil.isNotEmpty(item.getRefObjInfos())) {
                for(TyplmBaseLineCompareObjInfo itemObj : item.getRefObjInfos()) {
                    identifier = new IdentifierEntity();
                    identifier.setOid(itemObj.getOid());
                    identifier.setOtype(itemObj.getOtype());
                    resultData.add(identifier);
                }
            }
        }

        TyplmLoggerUtil.debug(log, () -> "getIdentifierEntityByResultsVo ==> voList =【{}】", () -> new Object[]{JSON.toJSONString(voList)});
        return resultData;
    }

    private void setPerssmission(HashMap<IdentifierEntity, Integer> canReadObjList, List<TyplmBaseLineComparisonResultsVO> voList) {
        TyplmLoggerUtil.debug(log, () -> "setPerssmission ==> canReadObjList =【{}】,voList=【{}】", () -> new Object[]{JSON.toJSONString(canReadObjList), JSON.toJSONString(voList)});

        for(TyplmBaseLineComparisonResultsVO item : voList) {
            IdentifierEntity identifier = new IdentifierEntity();
            identifier.setOid(item.getOid());
            identifier.setOtype(item.getOtype());
            if (canReadObjList.containsKey(identifier)) {
                item.setCanRead((Integer)canReadObjList.get(identifier));
            }

            if (CollUtil.isNotEmpty(item.getRefObjInfos())) {
                for(TyplmBaseLineCompareObjInfo itemObj : item.getRefObjInfos()) {
                    identifier = new IdentifierEntity();
                    identifier.setOid(itemObj.getOid());
                    identifier.setOtype(itemObj.getOtype());
                    if (canReadObjList.containsKey(identifier)) {
                        itemObj.setCanRead((Integer)canReadObjList.get(identifier));
                    }
                }
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setPerssmission <== voList =【{}】", () -> new Object[]{JSON.toJSONString(voList)});
    }

    private List<TyplmBaseLineComparisonResultsVO> compareDataToResultData(List<TyplmBaseLineCompareSearchData> dataList) {
        TyplmLoggerUtil.debug(log, () -> "compareDataToResultData ==> dataList =【{}】", () -> new Object[]{JSON.toJSONString(dataList)});
        List<TyplmBaseLineComparisonResultsVO> result = new ArrayList();
        List<String> lifeCycleStateCodeList = (List)dataList.stream().map(TyplmBaseLineCompareSearchData::getLifecyclestagekey).collect(Collectors.toList());
        Map<String, String> lifeCycleStateCodeMap = this.typlmLocalePropertyValueService.queryLocaleValueByItem((Collection)lifeCycleStateCodeList.stream().distinct().collect(Collectors.toList()), "LifeCycleState", TyCommonExtUtil.getFrontLanguage());
        dataList.forEach((vo) -> vo.setLifecyclestagename((String)lifeCycleStateCodeMap.getOrDefault(vo.getLifecyclestagekey(), vo.getLifecyclestagekey())));
        List<BigInteger> lifecycleTemplateOidList = (List)dataList.stream().filter((t) -> ObjectUtil.isNotEmpty(t.getLifecycletemplateoid())).map(TyplmBaseLineCompareSearchData::getLifecycletemplateoid).collect(Collectors.toList());
        Map<BigInteger, String> lifecycleTemplateNameMap = lifecycleTemplateOidList.isEmpty() ? Collections.emptyMap() : (Map)this.typlmLifecycleStageTemplateService.selectStageListByTemplate(lifecycleTemplateOidList).stream().collect(Collectors.toMap(TyTemplateAndStatusDTO::getTemplateoid, TyTemplateAndStatusDTO::getTemplatename, (k1, k2) -> k1));
        List<BigInteger> subFolderIds = new ArrayList();

        for(TyplmBaseLineCompareSearchData queryBaseLineVO : dataList) {
            if (queryBaseLineVO.getSubfolderoid() != null) {
                subFolderIds.add(queryBaseLineVO.getSubfolderoid());
            }
        }

        Map<BigInteger, String> bigIntegerStringMap = this.typlmProductFolderService.recursiveQueryFolderPathByIdList(subFolderIds);
        dataList.forEach((item) -> {
            TyplmBaseLineComparisonResultsVO resultsVO = new TyplmBaseLineComparisonResultsVO();
            BeanUtil.copyProperties(item, resultsVO, true);
            resultsVO.setOid(item.getOid());
            resultsVO.setOtype(item.getOtype());
            resultsVO.setNumber(item.getNumber());
            resultsVO.setDisplayName(item.getDisplayName());
            resultsVO.setName(item.getName());
            resultsVO.setDescription(item.getDescription());
            resultsVO.setLockor(item.getLockor());
            resultsVO.setLockorDisplayName(item.getLockorDisplayName());
            resultsVO.setIsProtectedValue(item.getIsProtected());
            resultsVO.setIsProtected(item.getIsProtected() == 1 ? BaseLineErrorCodeEnum.BASELINE_WORD_YES.getLocaleMessage() : BaseLineErrorCodeEnum.BASELINE_WORD_NO.getLocaleMessage());
            resultsVO.setLifecyclestagekey(item.getLifecyclestagekey());
            resultsVO.setLifecyclestagename(item.getLifecyclestagename());
            resultsVO.setSubfolderoid(item.getSubfolderoid());
            resultsVO.setIslocked(item.getIslocked());
            resultsVO.setType((String)FolderQueryConstant.QUERY_OTYPE_TO_TYPE_MAP.getOrDefault(item.getOtype(), item.getOtype()));
            resultsVO.setTypeoid(item.getTypeoid());
            resultsVO.setTypeotype(item.getTypeotype());
            resultsVO.setTypeDefName(item.getTypeDefName());
            resultsVO.setIslockedText(item.getIslocked() != null && item.getIslocked() != 0 ? BaseLineErrorCodeEnum.BASELINE_WORD_YES.getLocaleMessage() : BaseLineErrorCodeEnum.BASELINE_WORD_NO.getLocaleMessage());
            if (Objects.nonNull(item.getTopobjectoid()) && item.getTopobjectoid().compareTo(BigInteger.valueOf(0L)) != 0) {
                resultsVO.setTopobjectoid(item.getTopobjectoid());
            }

            BigInteger subfolderId = item.getSubfolderoid() == null ? BigInteger.ZERO : item.getSubfolderoid();
            if (bigIntegerStringMap.containsKey(subfolderId)) {
                resultsVO.setFolderPath((String)bigIntegerStringMap.get(subfolderId));
            }

            if (item.getLifecycletemplateoid() != null && lifecycleTemplateNameMap.containsKey(item.getLifecycletemplateoid())) {
                resultsVO.setLifeCycleTemplateName((String)lifecycleTemplateNameMap.get(item.getLifecycletemplateoid()));
            }

            this.setClassInfo(resultsVO);
            result.add(resultsVO);
        });
        TyplmLoggerUtil.debug(log, () -> "compareDataToResultData <== result =【{}】", () -> new Object[]{JSON.toJSONString(result)});
        return result;
    }

    private void setClassInfo(TyplmBaseLineComparisonResultsVO baseLineInfo) {
        TyplmLoggerUtil.debug(log, () -> "setClassInfo ==> baseLineInfo =【{}】", () -> new Object[]{JSON.toJSONString(baseLineInfo)});
        Map<String, Object> classInfoMap = this.typlmClassificationService.queryClassNameByCondition(baseLineInfo.getOid(), baseLineInfo.getOtype());
        if (MapUtil.isNotEmpty(classInfoMap)) {
            if (ObjectUtils.isNotEmpty(classInfoMap.get("oid"))) {
                baseLineInfo.setClassOid(classInfoMap.get("oid").toString());
            }

            if (ObjectUtils.isNotEmpty(classInfoMap.get("displayName"))) {
                baseLineInfo.setClassName(classInfoMap.get("displayName").toString());
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setClassInfo <== baseLineInfo =【{}】", () -> new Object[]{JSON.toJSONString(baseLineInfo)});
    }

    private void getCompareObjData(List<IdentifierEntity> baselineList, List<TyplmBaseLineComparisonResultsVO> resultsVOS) {
        TyplmLoggerUtil.debug(log, () -> "getCompareObjData获取比较的对象数据 ==> baselineList =【{}】", () -> new Object[]{JSON.toJSONString(baselineList)});
        List<BigInteger> oidList = (List)baselineList.stream().map(IdentifierEntity::getOid).collect(Collectors.toList());
        List<String> tableTypeList = BatchQueryHelper.batchSplitQuery(oidList, (list) -> this.typlmBaseLineMemberMapper.queryObjTypeByBaseLine(new ArrayList(list)));
        if (!CollUtil.isEmpty(resultsVOS)) {
            TyplmBaseLineMemberParam param = new TyplmBaseLineMemberParam();
            param.setOidList(oidList);
            List<TableParamDTO> resultList = new ArrayList();
            tableTypeList.forEach((otype) -> {
                TableParamDTO table = TyplmEntityBaseUtil.getTableParamDTO(otype);
                resultList.add(table);
            });
            param.setTableParam(resultList);
            if (!CollUtil.isEmpty(resultList) && !CollUtil.isEmpty(param.getOidList())) {
                List<TyplmBaseLineCompareObjInfo> objDataList = this.typlmBaseLineMemberMapper.queryCompareObjInfoByBaseLine(param);
                if (!CollUtil.isEmpty(objDataList)) {
                    List<BigInteger> typeOidList = (List)objDataList.stream().filter((item) -> Objects.nonNull(item.getTypeoid())).map(TyplmBaseLineCompareObjInfo::getTypeoid).distinct().collect(Collectors.toList());
                    List<BigInteger> cadOids = (List)objDataList.stream().filter((item) -> item.getOtype().equalsIgnoreCase("ty.inteplm.cad.CTyCADDoc")).map(TyplmBaseLineObjBaseVO::getOid).collect(Collectors.toList());
                    List<TypeVueVO> iconList = this.typlmTypeService.queryTypeByIds(typeOidList);
                    this.typlmBaseLineMemberService.setCompareInfoDisplayNameList(objDataList);
                    Map<BigInteger, CADDocDO> oidToCadMap;
                    if (!CollectionUtils.isEmpty(cadOids)) {
                        oidToCadMap = (Map)this.typlmCADDocService.queryCADDocByOIDs(cadOids).stream().collect(Collectors.toMap(CADDocDO::getOid, Function.identity()));
                    } else {
                        oidToCadMap = new HashMap<>();
                    }

                    Map<String, String> familyTableStatusToIconMap = this.typlmTypeService.getFamilyTableStatusToIconMap();
                    objDataList.forEach((item) -> {
                        TypeVueVO typeInfo = (TypeVueVO)iconList.stream().filter((itemV) -> Objects.nonNull(item.getTypeoid()) && item.getTypeoid().compareTo(itemV.getOid()) == 0).findFirst().orElse(null);
                        if (Objects.nonNull(typeInfo)) {
                            item.setTypeIcon(typeInfo.getIcon());
                            item.setTypeDefName(typeInfo.getDisplayName());
                            item.setIcon(typeInfo.getIcon());
                        }

                        if ("ty.inteplm.cad.CTyCADDoc".equalsIgnoreCase(item.getOtype()) && oidToCadMap.containsKey(item.getOid())) {
                            CADDocDO cadDocDO = (CADDocDO)oidToCadMap.get(item.getOid());
                            if (cadDocDO != null) {
                                item.setIcon((String)familyTableStatusToIconMap.getOrDefault(String.valueOf(cadDocDO.getFamilytablestatus()), item.getTypeIcon()));
                            }
                        }

                    });
                    List<CTyEntityBaseDO> cTyEntityBaseDOList = (List)objDataList.stream().filter((item) -> StringUtils.isEmpty(item.getDisplayName())).map((item) -> {
                        CTyEntityBaseDO baseDO = new CTyEntityBaseDO();
                        baseDO.setOtype(item.getOtype());
                        baseDO.setOid(item.getOid());
                        return baseDO;
                    }).collect(Collectors.toList());
                    if (CollUtil.isNotEmpty(cTyEntityBaseDOList)) {
                        Map<String, String> objDisplayMap = CommonUtil.getEntityDisplayNameList(cTyEntityBaseDOList);
                        if (CollUtil.isNotEmpty(objDisplayMap)) {
                            objDataList.forEach((item) -> {
                                CTyEntityBaseDO baseDO = new CTyEntityBaseDO();
                                baseDO.setOtype(item.getOtype());
                                baseDO.setOid(item.getOid());
                                if (objDisplayMap.containsKey(baseDO.getIdentifierRef().toString())) {
                                    item.setDisplayName((String)objDisplayMap.get(baseDO.getIdentifierRef().toString()));
                                }

                            });
                        }
                    }

                    resultsVOS.forEach((item) -> {
                        List<TyplmBaseLineCompareObjInfo> objInfos = (List)objDataList.stream().filter((x) -> x.getBaselineOid().compareTo(item.getOid()) == 0).collect(Collectors.toList());
                        List<TyplmBaseLineCompareObjInfo> objInfoDataList = new ArrayList();
                        objInfos.forEach((itemData) -> itemData.setType((String)FolderQueryConstant.QUERY_OTYPE_TO_TYPE_MAP.getOrDefault(itemData.getOtype(), itemData.getType())));
                        List<TyplmBaseLineCompareObjInfo> topObjInfos = new ArrayList();
                        if (Objects.nonNull(item.getTopobjectoid())) {
                            topObjInfos = (List)objInfos.stream().filter((itemObj) -> itemObj.getOid().compareTo(item.getTopobjectoid()) == 0).collect(Collectors.toList());
                            if (CollUtil.isNotEmpty(topObjInfos)) {
                                topObjInfos.forEach((itemValue) -> {
                                    itemValue.setIsTop(1);
                                    itemValue.setIsTopObject(1);
                                });
                                objInfos.removeAll(topObjInfos);
                            }
                        }

                        if (CollUtil.isNotEmpty(topObjInfos)) {
                            objInfoDataList.addAll(topObjInfos);
                        }

                        objInfoDataList.addAll(objInfos);
                        item.setRefObjInfos(objInfoDataList);
                    });
                    TyplmLoggerUtil.debug(log, () -> "getCompareObjData获取比较的对象数据 ==> resultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(resultsVOS)});
                }
            }
        }
    }

    private void compareBaseLineAttr(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "compareBaseLineAttr ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
        if (!CollUtil.isEmpty(comparisonResultsVOS)) {
            this.setDifferentTag(comparisonResultsVOS, param);
        }
    }

    private void setDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "setDifferentTag ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
        if (Boolean.FALSE.equals(param.getCompareBaseLineAttrs())) {
            HashMap<String, Integer> compareData = new HashMap();
            this.setNameDifferentTag(comparisonResultsVOS, compareData);
            this.setDescriptionDifferentTag(comparisonResultsVOS, compareData);
            this.setLockorDifferentTag(comparisonResultsVOS, compareData);
            this.setIsProtectedDifferentTag(comparisonResultsVOS, compareData);
            this.setLifecyclestageDifferentTag(comparisonResultsVOS, compareData);
            this.setResultVoAttrDifferentTag(comparisonResultsVOS, compareData);
        } else {
            this.getAttribute(comparisonResultsVOS, param);
        }

    }

    private void getAttribute(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "getAttribute ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(param)});
        List<BigInteger> oidList = (List)comparisonResultsVOS.stream().map(TyplmBaseLineComparisonResultsVO::getOid).collect(Collectors.toList());
        Map<String, List<AttributeVO>> ibaAttributeMap = this.typlmAttributeValueService.getIbaAttrValueByOidAndKeys(oidList, "ty.inteplm.baseline.CTyBaseLine", (List)null);
        LinkedHashMap<String, List<AttributeKeyValueVO>> attrNameMap = new LinkedHashMap();
        LinkedHashMap<String, List<AttributeKeyValueVO>> classAttrNameMap = new LinkedHashMap();
        TyplmLoggerUtil.debug(log, () -> "getAttribute ==> ibaAttributeMap =【{}】", () -> new Object[]{JSON.toJSONString(ibaAttributeMap)});
        List<BigInteger> typeOids = (List)comparisonResultsVOS.stream().map(TyplmBaseLineComparisonResultsVO::getTypeoid).distinct().collect(Collectors.toList());
        List<BigInteger> classifyOids = (List)comparisonResultsVOS.stream().map((typlmBaseLineComparisonResultsVO) -> CommonUtil.stringToBigInteger(typlmBaseLineComparisonResultsVO.getClassOid())).distinct().collect(Collectors.toList());
        this.buildMainAttrDataMap(comparisonResultsVOS, attrNameMap);
        this.buildIbaValueDataMap(comparisonResultsVOS, ibaAttributeMap, attrNameMap, classAttrNameMap);
        TyplmLoggerUtil.debug(log, () -> "getAttribute ==> attrNameMap =【{}】", () -> new Object[]{JSON.toJSONString(attrNameMap)});
        List<String> colList = this.getCompareColList(typeOids, classifyOids, param, attrNameMap, classAttrNameMap);
        TyplmLoggerUtil.debug(log, () -> "getAttribute 获取需要比对的属性==> colList =【{}】", () -> new Object[]{JSON.toJSONString(colList)});

        for(Map.Entry<String, List<AttributeKeyValueVO>> attrItem : attrNameMap.entrySet()) {
            if (classAttrNameMap.containsKey(attrItem.getKey()) && CollUtil.isNotEmpty((Collection)classAttrNameMap.get(attrItem.getKey()))) {
                ((List)attrItem.getValue()).addAll((Collection)classAttrNameMap.get(attrItem.getKey()));
            }
        }

        this.compareBaseLineAttr(comparisonResultsVOS, attrNameMap, colList);
    }

    private void compareBaseLineAttr(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, LinkedHashMap<String, List<AttributeKeyValueVO>> attrNameMap, List<String> colList) {
        LinkedHashMap<String, AttributeKeyValueVO> colAllListy = new LinkedHashMap();
        if (colList == null) {
            for(Map.Entry<String, List<AttributeKeyValueVO>> item : attrNameMap.entrySet()) {
                for(AttributeKeyValueVO itemValue : (List<AttributeKeyValueVO>)item.getValue()) {
                    if (!colAllListy.containsKey(itemValue.getKey())) {
                        colAllListy.put(itemValue.getKey(), itemValue);
                    }
                }
            }
        } else {
            if (CollUtil.isEmpty(colList)) {
                return;
            }

            for(Map.Entry<String, List<AttributeKeyValueVO>> item : attrNameMap.entrySet()) {
                for(AttributeKeyValueVO itemValue : item.getValue()) {
                    if (!colAllListy.containsKey(itemValue.getKey()) && colList.contains(itemValue.getKey())) {
                        colAllListy.put(itemValue.getKey(), itemValue);
                    }
                }
            }
        }

        if (!CollUtil.isEmpty(colAllListy)) {
            List<String> diffColKey = new ArrayList();

            for(TyplmBaseLineComparisonResultsVO item : comparisonResultsVOS) {
                List<AttributeKeyValueVO> itemDataList = new ArrayList();
                List<AttributeKeyValueVO> itemDefList = new ArrayList();
                if (attrNameMap.containsKey(item.getOid().toString())) {
                    itemDataList.addAll((Collection)attrNameMap.get(item.getOid().toString()));
                }

                for(Map.Entry<String, AttributeKeyValueVO> colKey : colAllListy.entrySet()) {
                    AttributeKeyValueVO colDef = (AttributeKeyValueVO)itemDataList.stream().filter((itemTemp) -> itemTemp.getKey().equalsIgnoreCase((String)colKey.getKey())).findFirst().orElse(null);
                    if (colDef == null) {
                        colDef = new AttributeKeyValueVO();
                        BeanUtils.copyProperties(colKey.getValue(), colDef);
                        colDef.setValue("");
                        colDef.setTextCN("");
                        itemDefList.add(colDef);
                        if (!diffColKey.contains(colDef.getKey())) {
                            diffColKey.add(colDef.getKey());
                        }
                    } else if (diffColKey.contains(colDef.getKey())) {
                        itemDefList.add(colDef);
                    } else {
                        boolean valueIsSame = true;

                        for(Map.Entry<String, List<AttributeKeyValueVO>> mainitem : attrNameMap.entrySet()) {
                            if (!((String)mainitem.getKey()).equalsIgnoreCase(item.getOid().toString())) {
                                if (!valueIsSame) {
                                    break;
                                }

                                AttributeKeyValueVO colother = (AttributeKeyValueVO)((List<AttributeKeyValueVO>)mainitem.getValue()).stream().filter((itemTemp) -> itemTemp.getKey().equalsIgnoreCase((String)colKey.getKey())).findFirst().orElse(null);
                                if (colother == null) {
                                    if (!diffColKey.contains(colDef.getKey())) {
                                        valueIsSame = false;
                                        break;
                                    }
                                } else if (!StringUtils.equals(colother.getValue(), colDef.getValue())) {
                                    valueIsSame = false;
                                    break;
                                }
                            }
                        }

                        if (!valueIsSame) {
                            itemDefList.add(colDef);
                            diffColKey.add(colDef.getKey());
                        }
                    }
                }

                item.setDiffAttr(itemDefList);
            }

            colAllListy.entrySet().forEach((itemx) -> {
                if (!comparisonResultsVOS.stream().anyMatch((itemInfo) -> itemInfo.getDiffAttr().stream().filter((itemAttr) -> itemAttr.getKey().equalsIgnoreCase((String)itemx.getKey())).anyMatch((itemAttr) -> StringUtils.isNotEmpty(itemAttr.getValue())))) {
                    comparisonResultsVOS.forEach((itemInfo) -> itemInfo.getDiffAttr().removeIf((itemAttr) -> itemAttr.getKey().equalsIgnoreCase((String)itemx.getKey())));
                }
            });
            TyplmLoggerUtil.debug(log, () -> "compareBaseLineAttr 基线属性比对结果==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
        }
    }

    private LinkedHashMap<String, String> getBaseLineMainAttr() {
        LinkedHashMap<String, String> attrMap = new LinkedHashMap();
        attrMap.put("number", "编码");
        attrMap.put("name", "名称");
        attrMap.put("displayName", "标识");
        attrMap.put("typeDefName", "类型");
        attrMap.put("className", "分类");
        attrMap.put("containerName", "上下文");
        attrMap.put("folderPath", "位置");
        attrMap.put("isProtected", "受保护");
        attrMap.put("islockedText", "锁定");
        attrMap.put("lockorDisplayName", "锁定人");
        attrMap.put("lifeCycleTemplateName", "生命周期模板");
        attrMap.put("lifecyclestagename", "状态");
        attrMap.put("creatorName", "创建者");
        attrMap.put("createstamp", "创建时间");
        attrMap.put("updatestamp", "最后修改时间");
        attrMap.put("updatecount", "修改次数");
        attrMap.put("description", "描述");
        TyplmLoggerUtil.debug(log, () -> "getBaseLineMainAttr ==> attrMap =【{}】", () -> new Object[]{JSON.toJSONString(attrMap)});
        return attrMap;
    }

    private List<String> getCompareColList(List<BigInteger> typeOids, List<BigInteger> classifyOidList, CompareBaseLineReportDTO param, LinkedHashMap<String, List<AttributeKeyValueVO>> attrNameMap, LinkedHashMap<String, List<AttributeKeyValueVO>> classAttrNameMa) {
        TyplmLoggerUtil.debug(log, () -> "getCompareColList ==> param =【{}】", () -> new Object[]{JSON.toJSONString(param)});
        List<String> keyListresult = null;
        if (CollUtil.isEmpty(param.getNeedCompareAttr())) {
            return keyListresult;
        } else {
            List<String> keyList = new ArrayList();
            boolean isNull = true;

            for(BigInteger item : typeOids) {
                if (param.getNeedCompareAttr().containsKey(item)) {
                    isNull = false;
                    List<String> colList = (List)param.getNeedCompareAttr().get(item);
                    if (CollUtil.isNotEmpty(colList)) {
                        keyList.addAll((Collection)colList.stream().filter((key) -> !keyList.contains(key)).collect(Collectors.toList()));
                    }
                } else {
                    TyplmLoggerUtil.debug(log, () -> "getCompareColList ==> keyListresult =【{}】", () -> new Object[]{JSON.toJSONString(keyListresult)});

                    for(Map.Entry<String, List<AttributeKeyValueVO>> attrItem : attrNameMap.entrySet()) {
                        keyList.addAll((Collection)((List<AttributeKeyValueVO>)attrItem.getValue()).stream().map(AttributeKeyValueVO::getKey).collect(Collectors.toList()));
                    }
                }
            }

            for(BigInteger item : classifyOidList) {
                if (param.getNeedCompareAttr().containsKey(item)) {
                    isNull = false;
                    List<String> colList = (List)param.getNeedCompareAttr().get(item);
                    if (CollUtil.isNotEmpty(colList)) {
                        keyList.addAll((Collection)colList.stream().filter((key) -> !keyList.contains(key)).collect(Collectors.toList()));
                    }
                } else {
                    TyplmLoggerUtil.debug(log, () -> "getCompareColList ==> keyListresult =【{}】", () -> new Object[]{JSON.toJSONString(keyListresult)});

                    for(Map.Entry<String, List<AttributeKeyValueVO>> attrItem : classAttrNameMa.entrySet()) {
                        keyList.addAll((Collection)((List<AttributeKeyValueVO>)attrItem.getValue()).stream().map(AttributeKeyValueVO::getKey).collect(Collectors.toList()));
                    }
                }
            }

            TyplmLoggerUtil.debug(log, () -> "getCompareColList ==> result =【{}】", () -> new Object[]{JSON.toJSONString(keyList)});
            return isNull ? null : (List)keyList.stream().distinct().collect(Collectors.toList());
        }
    }

    private void buildMainAttrDataMap(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, LinkedHashMap<String, List<AttributeKeyValueVO>> attrNameMap) {
        LinkedHashMap<String, String> attrMap = this.getBaseLineMainAttr();
        TyplmLoggerUtil.debug(log, () -> "buildMainAttrDataMap ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});

        for(TyplmBaseLineComparisonResultsVO item : comparisonResultsVOS) {
            List<AttributeKeyValueVO> itemCol = new ArrayList();
            JSONObject itemData = JSON.parseObject(JSON.toJSONString(item));
            JSONObject keyData = new JSONObject();

            for(Map.Entry<String, Object> keyValue : itemData.entrySet()) {
                keyData.put(((String)keyValue.getKey()).toLowerCase(), keyValue.getValue());
            }

            for(Map.Entry<String, String> itemAttr : attrMap.entrySet()) {
                String key = (String)itemAttr.getKey();
                AttributeKeyValueVO attributeKeyValueVO = new AttributeKeyValueVO();
                attributeKeyValueVO.setKey(key);
                attributeKeyValueVO.setTextEn(key);
                attributeKeyValueVO.setTextCN((String)attrMap.get(key));
                if (keyData.containsKey(key.toLowerCase())) {
                    attributeKeyValueVO.setValue(keyData.getString(key.toLowerCase()));
                }

                itemCol.add(attributeKeyValueVO);
            }

            if (attrNameMap.containsKey(item.getOid().toString())) {
                ((List)attrNameMap.get(item.getOid().toString())).addAll(itemCol);
            } else {
                attrNameMap.put(item.getOid().toString(), itemCol);
            }
        }

        TyplmLoggerUtil.debug(log, () -> "buildMainAttrDataMap ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
    }

    private void buildIbaValueDataMap(List<TyplmBaseLineComparisonResultsVO> baselineData, Map<String, List<AttributeVO>> attributeVOMap, LinkedHashMap<String, List<AttributeKeyValueVO>> attrNameMap, LinkedHashMap<String, List<AttributeKeyValueVO>> classAttrNameMap) {
        TyplmLoggerUtil.debug(log, () -> "buildIbaValueDataMap ==> attributeVOMap =【{}】", () -> new Object[]{JSON.toJSONString(attributeVOMap)});

        for(Map.Entry<String, List<AttributeVO>> item : attributeVOMap.entrySet()) {
            List<AttributeKeyValueVO> itemValueList = new ArrayList();
            List<AttributeKeyValueVO> classItemValueList = new ArrayList();
            TyplmBaseLineComparisonResultsVO baselineInfo = (TyplmBaseLineComparisonResultsVO)baselineData.stream().filter((itemInfo) -> itemInfo.getOid().toString().equalsIgnoreCase((String)item.getKey())).findFirst().orElse(null);
            if (!Objects.isNull(baselineInfo)) {
                List<TyAttributeDefMapVO> list = new ArrayList();
                list.addAll(this.typlmAttributeDefService.queryInheritAttrDef(baselineInfo.getTypeoid(), "ty.inteplm.type.CTyTypeDef"));
                list.addAll(this.typlmAttributeDefService.queryInheritAttrDef(TyplmEntityBaseUtil.getOidByStr(baselineInfo.getClassOid(), BigInteger.ZERO), "ty.inteplm.type.CTyClassification"));

                for(TyAttributeDefMapVO tyAttributeDefMapVO : list) {
                    AttributeKeyValueVO itemValueInfo = new AttributeKeyValueVO();
                    AttributeVO attributeVO1 = (AttributeVO)((List<AttributeVO>)item.getValue()).stream().filter((attributeVO) -> attributeVO.getAttributeOid().equalsIgnoreCase(tyAttributeDefMapVO.getAttributereferenceoid().toString())).findFirst().orElse(null);
                    itemValueInfo.setKey(tyAttributeDefMapVO.getAttributereferenceoid().toString());
                    itemValueInfo.setValue(attributeVO1 == null ? "" : attributeVO1.getAttributeValue());
                    itemValueInfo.setTextCN(tyAttributeDefMapVO.getIbaDefDisplayName());
                    itemValueInfo.setTextEn(tyAttributeDefMapVO.getIbaDefInnerName());
                    if ("ty.inteplm.type.CTyTypeDef".equalsIgnoreCase(tyAttributeDefMapVO.getTypeotype())) {
                        itemValueList.add(itemValueInfo);
                    } else {
                        classItemValueList.add(itemValueInfo);
                    }
                }

                if (attrNameMap.containsKey(item.getKey())) {
                    ((List)attrNameMap.get(item.getKey())).addAll(itemValueList);
                } else {
                    attrNameMap.put(item.getKey(), itemValueList);
                }

                if (classAttrNameMap.containsKey(item.getKey())) {
                    ((List)classAttrNameMap.get(item.getKey())).addAll(classItemValueList);
                } else {
                    classAttrNameMap.put(item.getKey(), classItemValueList);
                }
            }
        }

        TyplmLoggerUtil.debug(log, () -> "buildIbaValueDataMap ==> attributeVOMap =【{}】", () -> new Object[]{JSON.toJSONString(attributeVOMap)});
    }

    private void setResultVoAttrDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        for(TyplmBaseLineComparisonResultsVO item : comparisonResultsVOS) {
            if (compareData.containsKey(name) && ((Integer)compareData.get(name)).compareTo(1) == 0) {
                item.setNameDifferentTag(1);
            } else {
                item.setNameDifferentTag(0);
            }

            if (StringUtils.isBlank(item.getName())) {
                item.setName("--");
            }

            if (compareData.containsKey(description) && ((Integer)compareData.get(description)).compareTo(1) == 0) {
                item.setDescriptionDifferentTag(1);
            } else {
                item.setDescriptionDifferentTag(0);
            }

            if (StringUtils.isBlank(item.getDescription())) {
                item.setDescription("--");
            }

            if (compareData.containsKey(lockor) && ((Integer)compareData.get(lockor)).compareTo(1) == 0) {
                item.setLockorDifferentTag(1);
            } else {
                item.setLockorDifferentTag(0);
            }

            if (StringUtils.isBlank(item.getLockorDisplayName())) {
                item.setLockorDisplayName("--");
            }

            if (compareData.containsKey(isProtected) && ((Integer)compareData.get(isProtected)).compareTo(1) == 0) {
                item.setIsProtectedDifferentTag(1);
            } else {
                item.setIsProtectedDifferentTag(0);
            }

            if (compareData.containsKey(lifecyclestage) && ((Integer)compareData.get(lifecyclestage)).compareTo(1) == 0) {
                item.setLifecyclestageDifferentTag(1);
            } else {
                item.setLifecyclestageDifferentTag(0);
            }

            if (StringUtils.isBlank(item.getLifecyclestagename())) {
                item.setLifecyclestagename("--");
            }
        }

        TyplmLoggerUtil.debug(log, () -> "setResultVoAttrDifferentTag ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
    }

    private void setNameDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        TyplmBaseLineComparisonResultsVO item = (TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0);
        if (comparisonResultsVOS.stream().noneMatch((x) -> x.getOid().compareTo(((TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0)).getOid()) != 0 && (Objects.isNull(x.getName()) || Objects.isNull(item.getName()) || !x.getName().equals(item.getName())))) {
            compareData.put(name, 0);
        } else {
            compareData.put(name, 1);
        }

    }

    private void setDescriptionDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        TyplmBaseLineComparisonResultsVO item = (TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0);
        if (comparisonResultsVOS.stream().noneMatch((x) -> x.getOid().compareTo(((TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0)).getOid()) != 0 && (Objects.isNull(x.getDescription()) && Objects.nonNull(item.getDescription()) || Objects.nonNull(x.getDescription()) && Objects.isNull(item.getDescription()) || Objects.nonNull(x.getDescription()) && !x.getDescription().equals(item.getDescription()) || Objects.nonNull(item.getDescription()) && !item.getDescription().equals(x.getDescription())))) {
            compareData.put(description, 0);
        } else {
            compareData.put(description, 1);
        }

    }

    private void setLockorDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        TyplmBaseLineComparisonResultsVO item = (TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0);
        if (comparisonResultsVOS.stream().noneMatch((x) -> x.getOid().compareTo(((TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0)).getOid()) != 0 && (StringUtils.isBlank(x.getLockor()) && StringUtils.isNotBlank(item.getLockor()) || StringUtils.isNotBlank(x.getLockor()) && StringUtils.isBlank(item.getLockor()) || StringUtils.isNotBlank(x.getLockor()) && StringUtils.isNotBlank(item.getLockor()) && !x.getLockor().equals(item.getLockor())))) {
            compareData.put(lockor, 0);
        } else {
            compareData.put(lockor, 1);
        }

    }

    private void setIsProtectedDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        TyplmBaseLineComparisonResultsVO item = (TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0);
        if (comparisonResultsVOS.stream().noneMatch((x) -> x.getOid().compareTo(((TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0)).getOid()) != 0 && (Objects.isNull(x.getIsProtected()) || Objects.isNull(item.getIsProtected()) || !x.getIsProtected().equals(item.getIsProtected())))) {
            compareData.put(isProtected, 0);
        } else {
            compareData.put(isProtected, 1);
        }

    }

    private void setLifecyclestageDifferentTag(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<String, Integer> compareData) {
        TyplmBaseLineComparisonResultsVO item = (TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0);
        if (comparisonResultsVOS.stream().noneMatch((x) -> x.getOid().compareTo(((TyplmBaseLineComparisonResultsVO)comparisonResultsVOS.get(0)).getOid()) != 0 && (Objects.isNull(x.getLifecyclestagekey()) || Objects.isNull(item.getLifecyclestagekey()) || !x.getLifecyclestagekey().equals(item.getLifecyclestagekey())))) {
            compareData.put(lifecyclestage, 0);
        } else {
            compareData.put(lifecyclestage, 1);
        }

    }

    private void compareRefObj(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS) {
        List<BigInteger> baseLineOidList = (List)comparisonResultsVOS.stream().map(TyplmBaseLineComparisonResultsVO::getOid).collect(Collectors.toList());
        HashMap<BigInteger, List<TyplmBaseLineCompareObjInfo>> refObjectAllMap = new HashMap();
        List<TyplmBaseLineCompareObjInfo> runAllObjList = new ArrayList();

        for(BigInteger oid : baseLineOidList) {
            List<TyplmBaseLineComparisonResultsVO> searchData = (List)comparisonResultsVOS.stream().filter((item) -> oid.compareTo(item.getOid()) == 0).collect(Collectors.toList());
            if (!CollUtil.isEmpty(searchData)) {
                TyplmBaseLineComparisonResultsVO itemInfo = (TyplmBaseLineComparisonResultsVO)searchData.get(0);
                List<TyplmBaseLineComparisonResultsVO> otherItemInfos = (List)comparisonResultsVOS.stream().filter((item) -> oid.compareTo(item.getOid()) != 0).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(itemInfo.getRefObjInfos())) {
                    for(TyplmBaseLineCompareObjInfo objInfo : itemInfo.getRefObjInfos()) {
                        if (!runAllObjList.stream().anyMatch((item) -> item.getMasterOID().compareTo(objInfo.getMasterOID()) == 0)) {
                            List<TyplmBaseLineCompareObjInfo> objList = new ArrayList();
                            if (Objects.isNull(objInfo.getTargetMasterOid()) || Objects.isNull(objInfo.getTargetDisplayName())) {
                                objInfo.setTargetMasterOid(objInfo.getMasterOID());
                                objInfo.setTargetDisplayName(objInfo.getDisplayName());
                            }

                            this.compareObjData(objInfo, otherItemInfos, objList);
                            this.addRefObjectToMap(objList, refObjectAllMap);
                            runAllObjList.add(objInfo);
                        }
                    }
                }
            }
        }

        this.setRefObjList(comparisonResultsVOS, refObjectAllMap);
        TyplmLoggerUtil.debug(log, () -> "compareRefObj ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
    }

    private void compareObjData(TyplmBaseLineCompareObjInfo objInfo, List<TyplmBaseLineComparisonResultsVO> otherItemInfos, List<TyplmBaseLineCompareObjInfo> objList) {
        Boolean isSame = true;
        TyplmLoggerUtil.debug(log, () -> "compareObjData ==> objInfo =【{}】,otherItemInfos=【{}】", () -> new Object[]{JSON.toJSONString(objInfo), JSON.toJSONString(otherItemInfos)});

        for(TyplmBaseLineComparisonResultsVO baselineInfo : otherItemInfos) {
            if (CollUtil.isNotEmpty(baselineInfo.getRefObjInfos())) {
                List<TyplmBaseLineCompareObjInfo> objListTemp = (List)baselineInfo.getRefObjInfos().stream().filter((item) -> item.getMasterOID().compareTo(objInfo.getMasterOID()) == 0).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(objListTemp)) {
                    if (((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).getOid().compareTo(objInfo.getOid()) == 0) {
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setDifferentTag(0);
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setTargetMasterOid(objInfo.getMasterOID());
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setTargetDisplayName(objInfo.getDisplayName());
                        if (objInfo.getIsTop() == 1) {
                            ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setIsTopObject(1);
                        } else if (Integer.valueOf(1).compareTo(((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).getIsTop()) == 0) {
                            objInfo.setIsTopObject(1);
                        }

                        objList.add(objListTemp.get(0));
                    } else {
                        isSame = false;
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setDifferentTag(1);
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setTargetMasterOid(objInfo.getMasterOID());
                        ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setTargetDisplayName(objInfo.getDisplayName());
                        if (objInfo.getIsTop() == 1) {
                            ((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).setIsTopObject(1);
                        } else if (Integer.valueOf(1).compareTo(((TyplmBaseLineCompareObjInfo)objListTemp.get(0)).getIsTop()) == 0) {
                            objInfo.setIsTop(1);
                        }

                        objList.add(objListTemp.get(0));
                    }
                } else {
                    isSame = false;
                    TyplmBaseLineCompareObjInfo objInfoTemp = new TyplmBaseLineCompareObjInfo();
                    objInfoTemp.setTargetMasterOid(objInfo.getMasterOID());
                    objInfoTemp.setTargetDisplayName(objInfo.getDisplayName());
                    objInfoTemp.setDifferentTag(1);
                    objInfoTemp.setDisplayName("--");
                    objInfoTemp.setBaselineOid(baselineInfo.getOid());
                    if (objInfo.getIsTop() == 1) {
                        objInfoTemp.setIsTopObject(1);
                    }

                    objList.add(objInfoTemp);
                }
            } else {
                TyplmBaseLineCompareObjInfo objInfoTemp = new TyplmBaseLineCompareObjInfo();
                objInfoTemp.setTargetMasterOid(objInfo.getMasterOID());
                objInfoTemp.setTargetDisplayName(objInfo.getDisplayName());
                objInfoTemp.setDifferentTag(1);
                objInfoTemp.setDisplayName("--");
                objInfoTemp.setBaselineOid(baselineInfo.getOid());
                if (objInfo.getIsTop() == 1) {
                    objInfoTemp.setIsTopObject(1);
                }

                objList.add(objInfoTemp);
                isSame = false;
            }
        }

        if (Boolean.TRUE.equals(isSame)) {
            objInfo.setDifferentTag(0);
        } else {
            objInfo.setDifferentTag(1);
        }

        objList.add(objInfo);
        if (objList.stream().anyMatch((item) -> item.getDifferentTag() == 1)) {
            objList.forEach((item) -> {
                item.setDifferentTag(1);
                item.setTargetMasterOid(objInfo.getTargetMasterOid());
                item.setTargetDisplayName(objInfo.getTargetDisplayName());
                if (objInfo.getIsTop() == 1) {
                    item.setIsTopObject(1);
                }

            });
        } else {
            objList.forEach((item) -> {
                item.setDifferentTag(0);
                item.setTargetMasterOid(objInfo.getTargetMasterOid());
                item.setTargetDisplayName(objInfo.getTargetDisplayName());
                if (objInfo.getIsTop() == 1) {
                    item.setIsTopObject(1);
                }

            });
        }

        TyplmLoggerUtil.debug(log, () -> "compareObjData <== objList =【{}】", () -> new Object[]{JSON.toJSONString(objList)});
    }

    private void setRefObjList(List<TyplmBaseLineComparisonResultsVO> comparisonResultsVOS, HashMap<BigInteger, List<TyplmBaseLineCompareObjInfo>> refObjectAllMap) {
        comparisonResultsVOS.forEach((item) -> {
            if (refObjectAllMap.containsKey(item.getOid())) {
                List<TyplmBaseLineCompareObjInfo> refObjList = (List)refObjectAllMap.get(item.getOid());
                refObjList.sort(Comparator.comparing(TyplmBaseLineCompareObjInfo::getIsTopObject).reversed().thenComparing(TyplmBaseLineCompareObjInfo::getTargetDisplayName));
                item.setRefObjInfos(refObjList);
            }

        });
        TyplmLoggerUtil.debug(log, () -> "setRefObjList ==> comparisonResultsVOS =【{}】", () -> new Object[]{JSON.toJSONString(comparisonResultsVOS)});
    }

    private void addRefObjectToMap(List<TyplmBaseLineCompareObjInfo> objInfos, HashMap<BigInteger, List<TyplmBaseLineCompareObjInfo>> map) {
        objInfos.forEach((item) -> {
            BigInteger baselineOid = item.getBaselineOid();
            if (map.containsKey(baselineOid)) {
                if (CollUtil.isNotEmpty((Collection)map.get(baselineOid))) {
                    List<TyplmBaseLineCompareObjInfo> data = (List)map.get(baselineOid);
                    data.add(item);
                    map.put(baselineOid, data);
                } else {
                    List<TyplmBaseLineCompareObjInfo> data = new ArrayList();
                    data.add(item);
                    map.put(baselineOid, data);
                }
            } else {
                List<TyplmBaseLineCompareObjInfo> data = new ArrayList();
                data.add(item);
                map.put(baselineOid, data);
            }

        });
    }

    public void exportBaseLineComparisonResults(HttpServletResponse response, List<TyplmBaseLineComparisonResultsVO> baselineList) {
        TyplmLoggerUtil.debug(log, () -> "exportBaseLineComparisonResults基线比较结果导出 ==> baselineList =【{}】", () -> new Object[]{JSON.toJSONString(baselineList)});
        if (CollUtil.isEmpty(baselineList)) {
            throw BaseLineErrorCodeEnum.BASELINE_COMPARE_DATA_NO_ERROR.getException(new Object[0]);
        } else {
            HSSFWorkbook workbook = this.writerExcelData(baselineList);
            this.downExportData(response, BaseLineErrorCodeEnum.BASELINE_COMPARE_FILE_NAME.getLocaleMessage() + System.currentTimeMillis() + ".xls", workbook);
        }
    }

    private HSSFWorkbook writerExcelData(List<TyplmBaseLineComparisonResultsVO> baselineList) {
        TyplmLoggerUtil.debug(log, () -> "writerExcelData ==> baselineList =【{}】", () -> new Object[]{JSON.toJSONString(baselineList)});
        HSSFWorkbook workbook = new HSSFWorkbook();
        short baselineColor = IndexedColors.GREY_25_PERCENT.getIndex();
        short attrColor = IndexedColors.GREY_25_PERCENT.getIndex();
        short diffColor = IndexedColors.LIGHT_GREEN.getIndex();
        HashMap<String, HSSFCellStyle> styleMap = new HashMap();
        HSSFCellStyle baselineStyle = workbook.createCellStyle();
        baselineStyle.setAlignment(HorizontalAlignment.CENTER);
        baselineStyle.setFillForegroundColor(baselineColor);
        baselineStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        styleMap.put(baseline, baselineStyle);
        HSSFCellStyle attrStyle = workbook.createCellStyle();
        attrStyle.setAlignment(HorizontalAlignment.CENTER);
        attrStyle.setFillForegroundColor(attrColor);
        attrStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        styleMap.put(attr, attrStyle);
        HSSFCellStyle diffStyle = workbook.createCellStyle();
        diffStyle.setAlignment(HorizontalAlignment.CENTER);
        diffStyle.setFillForegroundColor(diffColor);
        diffStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        styleMap.put(diff, diffStyle);
        HSSFCellStyle defStyle = workbook.createCellStyle();
        defStyle.setAlignment(HorizontalAlignment.CENTER);
        styleMap.put(def, defStyle);
        HSSFSheet sheet = workbook.createSheet(BaseLineErrorCodeEnum.BASELINE_COMPARE_BASELINE_TITLE.getLocaleMessage());
        HSSFSheet sheetObj = workbook.createSheet(BaseLineErrorCodeEnum.BASELINE_COMPARE_OBJ_TITLE.getLocaleMessage());
        HSSFRow row = this.getRow(sheet, 1);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_ATTR_NAME.getLocaleMessage());
        row.getCell(0).setCellStyle(baselineStyle);
        row = this.getRow(sheet, 2);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_ATTR_DESCRIPTION.getLocaleMessage());
        row.getCell(0).setCellStyle(baselineStyle);
        row = this.getRow(sheet, 3);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_ATTR_LOCKOR.getLocaleMessage());
        row.getCell(0).setCellStyle(baselineStyle);
        row = this.getRow(sheet, 4);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_ATTR_ISPROTECTED.getLocaleMessage());
        row.getCell(0).setCellStyle(baselineStyle);
        row = this.getRow(sheet, 5);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_ATTR_LIFECYCLESTAGE.getLocaleMessage());
        row.getCell(0).setCellStyle(baselineStyle);
        int attColIndex = 1;
        int rowIndex = 1;

        for(TyplmBaseLineComparisonResultsVO item : baselineList) {
            rowIndex = 1;
            row = this.getRow(sheet, 0);
            row.createCell(attColIndex).setCellValue(item.getDisplayName());
            row.getCell(attColIndex).setCellStyle(baselineStyle);
            row = this.getRow(sheetObj, 0);
            row.createCell(attColIndex).setCellValue(item.getDisplayName());
            row.getCell(attColIndex).setCellStyle(baselineStyle);
            this.setAttrSheetCell(sheet, item, attColIndex, styleMap);
            if (!CollUtil.isEmpty(item.getRefObjInfos())) {
                for(int i = 0; i < item.getRefObjInfos().size(); ++i) {
                    TyplmBaseLineCompareObjInfo objInfo = (TyplmBaseLineCompareObjInfo)item.getRefObjInfos().get(i);
                    row = this.getRow(sheetObj, rowIndex);
                    row.createCell(0).setCellValue((double)rowIndex);
                    row.getCell(0).setCellStyle(defStyle);
                    row.createCell(attColIndex).setCellValue(objInfo.getDisplayName());
                    if (objInfo.getDifferentTag() == 1) {
                        row.getCell(attColIndex).setCellStyle(diffStyle);
                    } else {
                        row.getCell(attColIndex).setCellStyle(defStyle);
                    }

                    ++rowIndex;
                }

                sheet.autoSizeColumn(attColIndex);
                sheetObj.autoSizeColumn(attColIndex);
                ++attColIndex;
            }
        }

        for(int i = 0; i < attColIndex; ++i) {
            sheet.autoSizeColumn(i);
            sheetObj.autoSizeColumn(i);
        }

        setSizeColumn(sheet, attColIndex);
        setSizeColumn(sheetObj, attColIndex);
        return workbook;
    }

    private void setAttrSheetCell(HSSFSheet sheet, TyplmBaseLineComparisonResultsVO item, int attColIndex, HashMap<String, HSSFCellStyle> styleMap) {
        HSSFRow row = this.getRow(sheet, 1);
        row.createCell(attColIndex).setCellValue(item.getName());
        this.setDiffCellStyle(item.getNameDifferentTag(), row.getCell(attColIndex), styleMap);
        row = this.getRow(sheet, 2);
        row.createCell(attColIndex).setCellValue(item.getDescription());
        this.setDiffCellStyle(item.getDescriptionDifferentTag(), row.getCell(attColIndex), styleMap);
        row = this.getRow(sheet, 3);
        row.createCell(attColIndex).setCellValue(item.getLockorDisplayName());
        this.setDiffCellStyle(item.getLockorDifferentTag(), row.getCell(attColIndex), styleMap);
        row = this.getRow(sheet, 4);
        row.createCell(attColIndex).setCellValue(item.getIsProtected());
        this.setDiffCellStyle(item.getIsProtectedDifferentTag(), row.getCell(attColIndex), styleMap);
        row = this.getRow(sheet, 5);
        row.createCell(attColIndex).setCellValue(item.getLifecyclestagename());
        this.setDiffCellStyle(item.getLifecyclestageDifferentTag(), row.getCell(attColIndex), styleMap);
    }

    private void setDiffCellStyle(Integer diffTag, HSSFCell cell, HashMap<String, HSSFCellStyle> styleMap) {
        if (diffTag == 1) {
            cell.setCellStyle((HSSFCellStyle)styleMap.get(diff));
        } else {
            cell.setCellStyle((HSSFCellStyle)styleMap.get(def));
        }

    }

    private HSSFRow getRow(HSSFSheet sheet, int rowindex) {
        HSSFRow row = sheet.getRow(rowindex);
        if (row == null) {
            row = sheet.createRow(rowindex);
        }

        return row;
    }

    private static void setSizeColumn(HSSFSheet sheet, int size) {
        for(int columnNum = 0; columnNum < size; ++columnNum) {
            int columnWidth = sheet.getColumnWidth(columnNum) / 256;

            for(int rowNum = 0; rowNum < sheet.getLastRowNum(); ++rowNum) {
                HSSFRow currentRow;
                if (sheet.getRow(rowNum) == null) {
                    currentRow = sheet.createRow(rowNum);
                } else {
                    currentRow = sheet.getRow(rowNum);
                }

                columnWidth = setColumnWidth(currentRow, columnNum, columnWidth);
            }

            sheet.setColumnWidth(columnNum, columnWidth * 300);
        }

    }

    private static int setColumnWidth(HSSFRow currentRow, int columnNum, int columnWidth) {
        if (currentRow.getCell(columnNum) != null) {
            HSSFCell currentCell = currentRow.getCell(columnNum);
            if (currentCell.getCellType() == CellType.STRING) {
                int length = currentCell.getStringCellValue().getBytes().length;
                if (columnWidth < length) {
                    columnWidth = length;
                }
            }
        }

        return columnWidth;
    }

    private void downExportData(HttpServletResponse response, String fileName, HSSFWorkbook sheets) {
        try {
            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()).replace("\\+", "%20"));
            response.setHeader("Content-Type", "application/octet-stream");
            sheets.write(response.getOutputStream());
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            sheets.write(bos);
            byte[] bArray = bos.toByteArray();
            InputStream is = new ByteArrayInputStream(bArray);
            IOUtils.copyLarge(is, response.getOutputStream());
        } catch (IOException e) {
            log.error("singleFileDownload error:{}", e.getMessage());
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_IO_EXCEPTION, new String[]{e.getMessage()});
        }

    }

    public List<String> getBaselineMemberOtype() {
        return this.typlmTypeExtService.getControllerOtypeList(TyCommonConstant.CONTROLLED_BASELINEMEMBER_CONSTANT);
    }

    public List<TyplmBaseLineComparisonResultsVO> baselineCompareByView(CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "baselineCompareByView ==> param =【{}】", () -> new Object[]{JSON.toJSONString(param)});
        if (!Objects.isNull(param) && !CollUtil.isEmpty(param.getCompareInfoList())) {
            List<IdentifierEntity> baselineList = (List)param.getCompareInfoList().stream().filter((x) -> x.getOtype().equalsIgnoreCase("ty.inteplm.baseline.CTyBaseLine")).collect(Collectors.toList());
            if (CollUtil.isEmpty(baselineList)) {
                throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
            } else {
                return this.getBaseLineCompareData(param);
            }
        } else {
            throw BaseLineErrorCodeEnum.BASELINE_DATA_NO_ERROR.getException(new Object[0]);
        }
    }

    public void baselineCompareByViewExport(HttpServletResponse response, CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "baselineCompareByViewExport ==> param =【{}】", () -> new Object[]{JSON.toJSONString(param)});
        List<TyplmBaseLineComparisonResultsVO> result = this.baselineCompareByView(param);
        TyplmLoggerUtil.debug(log, () -> "baselineCompareByViewExport-baselineCompareByView ==> result =【{}】", () -> new Object[]{JSON.toJSONString(result)});
        this.exportBaseLineComparisonByViewResults(response, result, param);
    }

    public void exportBaseLineComparisonByViewResults(HttpServletResponse response, List<TyplmBaseLineComparisonResultsVO> baselineList, CompareBaseLineReportDTO param) {
        TyplmLoggerUtil.debug(log, () -> "exportBaseLineComparisonByViewResults ==> baselineList =【{}】,param=【{}】", () -> new Object[]{JSON.toJSONString(baselineList), JSON.toJSONString(param)});
        if (CollUtil.isEmpty(baselineList)) {
            throw BaseLineErrorCodeEnum.BASELINE_COMPARE_DATA_NO_ERROR.getException(new Object[0]);
        } else {
            List<String> displayList = (List)baselineList.stream().map((item) -> item.getNumber() + "," + item.getName()).collect(Collectors.toList());
            HSSFWorkbook workbook = this.writerExcelDataView(baselineList, param);
            this.downExportData(response, BaseLineErrorCodeEnum.BASELINE_COMPARE_EXCEL_FILENAME.getLocaleMessage(displayList.toArray()) + ".xls", workbook);
        }
    }

    private HSSFWorkbook writerExcelDataView(List<TyplmBaseLineComparisonResultsVO> baselineList, CompareBaseLineReportDTO param) {
        List<String> displayList = (List)baselineList.stream().map(TyplmBaseLineComparisonResultsVO::getDisplayName).collect(Collectors.toList());
        HSSFWorkbook workbook = new HSSFWorkbook();
        Font boldFont = workbook.createFont();
        boldFont.setFontName("Arial");
        boldFont.setFontHeightInPoints((short)10);
        boldFont.setBold(true);
        Font defFont = workbook.createFont();
        defFont.setFontName("Arial");
        defFont.setFontHeightInPoints((short)10);
        defFont.setBold(false);
        short baselineColor = IndexedColors.GREY_25_PERCENT.getIndex();
        short attrColor = IndexedColors.GREY_25_PERCENT.getIndex();
        HashMap<String, HSSFCellStyle> styleMap = new HashMap();
        HSSFCellStyle baselineStyle = workbook.createCellStyle();
        baselineStyle.setAlignment(HorizontalAlignment.LEFT);
        baselineStyle.setFillForegroundColor(baselineColor);
        baselineStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        baselineStyle.setBorderTop(BorderStyle.THIN);
        baselineStyle.setBorderLeft(BorderStyle.THIN);
        baselineStyle.setBorderRight(BorderStyle.THIN);
        baselineStyle.setBorderBottom(BorderStyle.THIN);
        baselineStyle.setFont(defFont);
        styleMap.put(baseline, baselineStyle);
        HSSFCellStyle attrStyle = workbook.createCellStyle();
        attrStyle.setAlignment(HorizontalAlignment.LEFT);
        attrStyle.setFillForegroundColor(attrColor);
        attrStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        attrStyle.setBorderTop(BorderStyle.THIN);
        attrStyle.setBorderLeft(BorderStyle.THIN);
        attrStyle.setBorderRight(BorderStyle.THIN);
        attrStyle.setBorderBottom(BorderStyle.THIN);
        attrStyle.setFont(defFont);
        styleMap.put(attr, attrStyle);
        HSSFCellStyle defStyle = workbook.createCellStyle();
        defStyle.setAlignment(HorizontalAlignment.LEFT);
        defStyle.setBorderTop(BorderStyle.THIN);
        defStyle.setBorderLeft(BorderStyle.THIN);
        defStyle.setBorderRight(BorderStyle.THIN);
        defStyle.setBorderBottom(BorderStyle.THIN);
        defStyle.setFont(defFont);
        styleMap.put(def, defStyle);
        HSSFCellStyle titleStyle = workbook.createCellStyle();
        titleStyle.setAlignment(HorizontalAlignment.CENTER);
        titleStyle.setBorderTop(BorderStyle.THIN);
        titleStyle.setBorderLeft(BorderStyle.THIN);
        titleStyle.setBorderRight(BorderStyle.THIN);
        titleStyle.setBorderBottom(BorderStyle.THIN);
        baselineStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        titleStyle.setFont(boldFont);
        styleMap.put(title, titleStyle);
        HSSFCellStyle blodStyle = workbook.createCellStyle();
        blodStyle.setAlignment(HorizontalAlignment.LEFT);
        blodStyle.setFont(boldFont);
        blodStyle.setBorderTop(BorderStyle.THIN);
        blodStyle.setBorderLeft(BorderStyle.THIN);
        blodStyle.setBorderRight(BorderStyle.THIN);
        blodStyle.setBorderBottom(BorderStyle.THIN);
        styleMap.put(blod, blodStyle);
        HSSFSheet sheet = workbook.createSheet(BaseLineErrorCodeEnum.BASELINE_COMPARE_EXCEL_SHEETTITLE.getLocaleMessage());
        int maxColIndex = baselineList.size() * 4 - 1;
        HSSFRow row = this.getRow(sheet, 0);
        row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_EXCEL_TITLE.getLocaleMessage(displayList.toArray()));
        row.getCell(0).setCellStyle(titleStyle);
        CellRangeAddress region = new CellRangeAddress(0, 0, 0, maxColIndex);
        sheet.addMergedRegion(region);
        this.setCellDefBorder(sheet, region);
        int startRowIndex = 1;
        CellRangeAddress cellRegion = null;
        int rowIndexAdd = 0;
        Boolean isFirstObj = true;
        int baseLineRowend = 0;
        int baseLineRowstart = startRowIndex;
        int objRowstart = 0;
        int objRowEnd = 0;
        int colIndex = 0;
        boolean isAttrFirstObj = true;

        for(TyplmBaseLineComparisonResultsVO item : baselineList) {
            int colItemIndex = colIndex * 4;
            if (Boolean.TRUE.equals(param.getCompareBaseLineAttrs())) {
                if (isAttrFirstObj) {
                    row = this.getRow(sheet, startRowIndex);
                    row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_EXCEL_ATTRTITLE.getLocaleMessage());
                    row.getCell(0).setCellStyle(blodStyle);
                    region = new CellRangeAddress(startRowIndex, startRowIndex, 0, maxColIndex);
                    sheet.addMergedRegion(region);
                    this.setCellDefBorder(sheet, region);
                    ++startRowIndex;
                }

                isAttrFirstObj = false;
                row = this.getRow(sheet, startRowIndex);
                row.createCell(colItemIndex).setCellValue(item.getDisplayName());
                row.getCell(colItemIndex).setCellStyle(baselineStyle);
                region = new CellRangeAddress(startRowIndex, startRowIndex, colItemIndex, (colIndex + 1) * 4 - 1);
                sheet.addMergedRegion(region);
                this.setCellDefBorder(sheet, region);
                int itemStartRowIndex = startRowIndex + 1;
                if (rowIndexAdd == 0) {
                    rowIndexAdd = item.getDiffAttr().size() + 1;
                }

                for(AttributeKeyValueVO attrInfo : item.getDiffAttr()) {
                    row = this.getRow(sheet, itemStartRowIndex);
                    row.createCell(colItemIndex).setCellValue(attrInfo.getTextCN());
                    row.getCell(colItemIndex).setCellStyle(defStyle);
                    row.createCell(colItemIndex + 1).setCellValue(StringUtils.isEmpty(attrInfo.getValue()) ? "" : attrInfo.getValue());
                    row.getCell(colItemIndex + 1).setCellStyle(defStyle);
                    cellRegion = new CellRangeAddress(itemStartRowIndex, itemStartRowIndex, colItemIndex + 1, (colIndex + 1) * 4 - 1);
                    sheet.addMergedRegion(cellRegion);
                    this.setCellDefBorder(sheet, region);

                    for(int i = colItemIndex + 2; i <= (colIndex + 1) * 4 - 1; ++i) {
                        row.createCell(i).setCellStyle(defStyle);
                    }

                    ++itemStartRowIndex;
                }
            }

            int itemObjStartRowIndex = startRowIndex + rowIndexAdd;
            if (baseLineRowend == 0) {
                baseLineRowend = itemObjStartRowIndex - 1;
            }

            if (Boolean.TRUE.equals(param.getCompareObjectAttrs())) {
                if (Boolean.TRUE.equals(isFirstObj)) {
                    row = this.getRow(sheet, itemObjStartRowIndex);
                    row.createCell(0).setCellValue(BaseLineErrorCodeEnum.BASELINE_COMPARE_EXCEL_OBJTITLE.getLocaleMessage());
                    row.getCell(0).setCellStyle(blodStyle);
                    region = new CellRangeAddress(itemObjStartRowIndex, itemObjStartRowIndex, 0, maxColIndex);
                    sheet.addMergedRegion(region);
                    this.setCellDefBorder(sheet, region);
                    if (objRowstart == 0) {
                        objRowstart = itemObjStartRowIndex;
                    }

                    ++itemObjStartRowIndex;
                } else {
                    ++itemObjStartRowIndex;
                }

                isFirstObj = false;
                row = this.getRow(sheet, itemObjStartRowIndex);
                row.createCell(colItemIndex).setCellValue(item.getDisplayName());
                row.getCell(colItemIndex).setCellStyle(baselineStyle);
                region = new CellRangeAddress(itemObjStartRowIndex, itemObjStartRowIndex, colItemIndex, (colIndex + 1) * 4 - 1);
                sheet.addMergedRegion(region);
                this.setCellDefBorder(sheet, region);
                ++itemObjStartRowIndex;
                row = this.getRow(sheet, itemObjStartRowIndex);
                row.createCell(colItemIndex).setCellValue("编号");
                row.getCell(colItemIndex).setCellStyle(baselineStyle);
                row = this.getRow(sheet, itemObjStartRowIndex);
                row.createCell(colItemIndex + 1).setCellValue("名称");
                row.getCell(colItemIndex + 1).setCellStyle(baselineStyle);
                row = this.getRow(sheet, itemObjStartRowIndex);
                row.createCell(colItemIndex + 2).setCellValue("版本");
                row.getCell(colItemIndex + 2).setCellStyle(baselineStyle);
                row = this.getRow(sheet, itemObjStartRowIndex);
                row.createCell(colItemIndex + 3).setCellValue("类型");
                row.getCell(colItemIndex + 3).setCellStyle(baselineStyle);
                ++itemObjStartRowIndex;
                if (CollUtil.isNotEmpty(item.getRefObjInfos())) {
                    int itemObjeAttrStartRowIndex = itemObjStartRowIndex;

                    for(TyplmBaseLineCompareObjInfo objInfo : item.getRefObjInfos()) {
                        row = this.getRow(sheet, itemObjeAttrStartRowIndex);
                        row.createCell(colItemIndex).setCellValue(objInfo.getNumber());
                        row.getCell(colItemIndex).setCellStyle(defStyle);
                        row = this.getRow(sheet, itemObjeAttrStartRowIndex);
                        row.createCell(colItemIndex + 1).setCellValue(objInfo.getName());
                        row.getCell(colItemIndex + 1).setCellStyle(defStyle);
                        row = this.getRow(sheet, itemObjeAttrStartRowIndex);
                        row.createCell(colItemIndex + 2).setCellValue(objInfo.getDisplayVersion());
                        row.getCell(colItemIndex + 2).setCellStyle(defStyle);
                        row = this.getRow(sheet, itemObjeAttrStartRowIndex);
                        row.createCell(colItemIndex + 3).setCellValue(objInfo.getTypeDefName());
                        row.getCell(colItemIndex + 3).setCellStyle(defStyle);
                        ++itemObjeAttrStartRowIndex;
                    }

                    if (objRowEnd == 0) {
                        objRowEnd = itemObjeAttrStartRowIndex - 1;
                    }
                }

                if (objRowEnd == 0) {
                    objRowEnd = itemObjStartRowIndex - 1;
                }
            }

            ++colIndex;
        }

        if (baseLineRowend > 0) {
            this.setCelBordBlack(sheet, baseLineRowstart, baseLineRowend, 0, maxColIndex);
        }

        if (objRowEnd > 0) {
            this.setCelBordBlack(sheet, objRowstart, objRowEnd, 0, maxColIndex);
        }

        for(int i = 0; i < maxColIndex + 1; ++i) {
            if (sheet.getColumnWidth(i) < 5000) {
                sheet.setColumnWidth(i, 5000);
            }
        }

        return workbook;
    }

    private void setCellDefBorder(HSSFSheet sheet, CellRangeAddress gradeItemRegion) {
        RegionUtil.setBorderBottom(BorderStyle.THIN, gradeItemRegion, sheet);
        RegionUtil.setBorderTop(BorderStyle.THIN, gradeItemRegion, sheet);
        RegionUtil.setBorderLeft(BorderStyle.THIN, gradeItemRegion, sheet);
        RegionUtil.setBorderRight(BorderStyle.THIN, gradeItemRegion, sheet);
    }

    private void setCelBordBlack(HSSFSheet sheet, int rowStart, int rowEnd, int colStart, int colEnd) {
        CellRangeAddress region = new CellRangeAddress(rowStart, rowEnd, colStart, colEnd);
        RegionUtil.setBorderBottom(BorderStyle.MEDIUM, region, sheet);
        RegionUtil.setBorderTop(BorderStyle.MEDIUM, region, sheet);
        RegionUtil.setBorderLeft(BorderStyle.MEDIUM, region, sheet);
        RegionUtil.setBorderRight(BorderStyle.MEDIUM, region, sheet);
    }

    public String getEntityOtype() {
        return "ty.inteplm.baseline.CTyBaseLine";
    }

    public CTyEntityBaseDO getEntityDO(BigInteger oid) {
        return (CTyEntityBaseDO)this.typlmBaseLineMapper.selectByPrimaryKey(oid);
    }

    public CTyEntityBaseDO getEntityDOByNumber(String number) {
        return this.queryBaseLineByNumber(number);
    }

    public List<? extends CTyEntityBaseDO> getEntityDOList(List<BigInteger> oidList) {
        List<String> baselineOidList = (List)oidList.stream().map(String::valueOf).collect(Collectors.toList());
        return this.queryBaseLineByoids(baselineOidList);
    }
}
